Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash: how do i choose rows from a file that have particular value in the column

I have a huge file that I need to analyze. What I want to do is separate those rows that have certain values in a certain column. So, its like choosing only those data that belong to a certain category. How can this be accomplished with a simple bash commnand or script.

For example, I want to separate only those rows which have values 1, 2 3 or 4 in the 8th column. The file is space delimited.

like image 461
sfactor Avatar asked Dec 13 '22 17:12

sfactor


1 Answers

You can use awk as:

awk '$8 == 1 || $8 == 2 || $8 == 3 || $8 == 4' file
like image 164
codaddict Avatar answered Dec 28 '22 23:12

codaddict