I have myfolder with this files:
ls myfolder
filefoo filebar filefoobar
For example, the content of filefoo is:
total: 379400041
cache_object://localhost/active_requests 379400041 6778 0-13955161 0-14111309 0-12250718 0-11422369 0-11901178 0-11781835 0-12687756 0-17663930 5-110207691 6-123940805 2-39477289 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0 0-0
bla bla bla
Note: the rest of the files have the same internal structure, but the numbers change
So the value I'm interested in extracting from these files is "total: number". this value is always in the first row of each file:
find myfolder -type f -exec awk '/^total:/{print $NF}' {} +
379400041
35402285
8589934592
And I should compare it with this variable:
max="1073741824"
So what I need is that if any of these values exceeds the $max variable (value > $max), it should output the file to an output list. Example (non-functional):
if (( "value" > "$max" )); then
# or if [ "value" -gt "$max" ]; then
the command to send the file to a list is missing > output.lst
else
echo "do nothing"
fi
expected output:
cat output.lst
filefoobar
Because filefoobar has 8589934592 and this value > $max
How to do that? thanks
Try this:
Note the use of grave accents, and that there are no spaces around the "=".
And of course there is no error checking here.