awk made easy
awk '/REGEX/ {print NR "\t" $9 "\t" $4"_"$5 ;}' file.txt
supports extended REGEX like perl ( e.g. [:blank:] Space or tab characters )
NR is line number
NF Number of fields
$n is the column to be printed, $0 is the whole row
if it only necessary to print columns of a file it is easier to use cut:
name -a | cut -d" " -f1,3,11,12
-d: or -d" " is the delimiter
-f1,3 are the fields to be displayed
other options: -s doesnt show lines without delimiters, --complement is selfesplicative
condition on a specific field:
$<field> ~ /<string>/ Search for string in specified field.
you can use awk also in pipes:
ll | awk 'NR!=1 {s+=$5} END {print "Average: " s/(NR-1)}'
END to process al file and then print results
tutorial on using awk from the command line:
http://www.vectorsite.net/tsawk_3.html#m1