Reputation: 4473
Let's say I have a file like:
thing1(space)thing2(space)thing3(space)thing4
E.g.
1 apple 3 4
3 banana 3 8
3 pear 11 12
13 cheeto 15 16
Can I only show lines where thing3
is greater than 3? (i.e. pear and cheeto)
I can easily do this in python, but can we do this in the shell? Maybe with awk? I'm still researching this.
Upvotes: 1
Views: 125
Reputation: 77135
You can do that easily with awk
if that is an option available to you by saying:
awk '$3>3' inputFile
$ cat file
1 apple 3 4
3 banana 3 8
3 pear 11 12
13 cheeto 15 16
$ awk '$3>3' file
3 pear 11 12
13 cheeto 15 16
awk
by default splits the line in to fields delimited by space and assigns them to variable which can be referenced by stating the column number. In your case you need to reference it by $3
.
Upvotes: 2