You are here

awk

stat -c %y vs.exe | awk '{printf $1 "\n"}'

I found awk one of the most useful tools (almost like grep or sed).
awk treats the input line as a (database) record containing fields, using (by default) the space character as the field separator (but a different field separator can be specified in the command).
Then you can refer to any field of the line using its index ($1, $2, $3, etc.)
Examples:
stat -c %y vs.exe | awk '{printf $1 ":" $3 "\n"}'
will print the first and the third fields on each line, putting ":" between the fields.
stat -c %y vs.exe | awk '{printf $1 ":" $3 }'
will print the same, but on one single output line, because there is no newline "\n" specified.

Apart from just printing specific parts (fields) of each line, you can perform calculations or sums based on them, and all in one command line.

from: http://www.linuxquestions.org/questions/programming-9/get-file-modificat...

Topic: