awk '{print $3}' input.txtUsing redirect to output the result to a file
awk '{print $3}' input.txt > output.txtTo get rid of dups from output.txt and output to file unique.txt:
sort output.txt | uniq -u > unique.txtWe can combine these steps to one:
awk '{print $3}' input.txt | sort | uniq -u > unique.txt
Some important info about awk:
- NR -- The current line's sequential number
- NF -- The number of fields in the current line
- FS -- The input field separator; defaults to whitespace and is reset by the -F command line parameter
path=" ../dist/myjar-1.7.jar"
jar_file=`echo $path | awk -F '/' '{print $NF}'`
print the sum of the number in a file:
file test.txt has the following format:
a=1.2
bc=2.3
xyz=1.3
awk -F '=' '{SUM += $NF} END {print SUM/NR}' test.txt
No comments:
Post a Comment