size=139
size=9292
size=140
size=139
size=139
size=10213
size=139
size=140
size=11186
size=139
size=139
size=140
size=12342
size=139
size=139
size=140
size=11360
How can I grep rows that has greater value than 1000 from size.txt ?
Also, is there any way that I could find this information from entire folder, which has many txt files like this ?
With awk:
awk -F= '$2 > 1000' filename
This can be used with many file names:
awk -F= '$2 > 1000' *
Or combined with find to do it to subfolders as well:
find directory -type f -exec awk -F= '$2 > 1000' '{}' \;
For the latter two, it may be desirable to print the file name as well as the actual result (mimicking the behavior of grep), which could be achieved like this:
awk -F= '$2 > 1000 { print FILENAME ": " $0 }' *
With bash builin commands:
while IFS="=" read variable value; do
[[ $value -gt 1000 ]] && echo "${variable}=${value}"
done < file
Output:
size=9292 size=10213 size=11186 size=12342 size=11360
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With