This is in reference to another question: How do I use robocopy to list all files over a certain size recursively?
I would like to parse output of a command (or cat a log file) and find a string value, convert it to an integer and then see if that integer value is greater than a given integer.
For instance, given the line:
*EXTRA File 78223 C:\_Google.Enterprise.Contract.2010-06-01.pdf
I'd like to compare '78223' to '10485760'. Is this possible with grep or sed?
Thanks!
Use
awk
as follows:Also - if you're using a Unix-like userland (like UnxUtils or Cygwin, if you're on Windows), you can use
find
with the-size
parameter to get your file list directly, and then pipe to xargs and do whatever you're trying to do with the selected files.The general answer to your question (interesting comparisons and other operations) is indeed awk or bash (with bc) or perl - but the specific scenario lends itself to
find
.In pure Bash:
Perl can be used similarly to awk:
echo '*EXTRA File 78223 C:\foo.pdf' | perl -ane 'print if $F[2] > 40000'