linux:awk
Table of Contents
AWK
Print Column
$ awk -F "," '{print $1}'
Use Env Var in AWK
Basic example. Notice that you do not use a $ sign when using the variable
NUMBER=4
echo | awk -v my_var=$NUMBER '{print "My var is " my_var}'
Produces the ouput
My var is 4
Search Where Column Has Value
To search a bunch of text where column 1 is made up of numbers and we only want to print the lines where the value of column 1 is greater than or equal to 100.
cat file | awk '$1 >= 100'
You could extend it using
cat file | awk '$1 >= 100 && $1 <= 999'
linux/awk.txt · Last modified: by bstafford
