Filtering records of a csv file based on a value of a column

Hi,

I tried filtering the records in a csv file using "awk" command listed below.

awk -F"~" '$4 ~ /Active/{print }' inputfile > outputfile

The output always has all the entries.

The same command worked for different users from one of the forum links.

content of file I was filtering is

user,user,user,Active
user,user,user,Arvhived
user,user,user,Active
user,user,user,Arvhived
user,user,user,Active
user,user,user,Arvhived
user,user,user,Active
user,user,user,Arvhived
user,user,user,Active
user,user,user,Arvhived
user,user,user,Active
user,user,user,Arvhived

Can some one please help me.

Many Thanks,

Best Regards,
Sunil.

Hi
try this
-F ","

--- Post updated at 14:52 ---

And even better like this

awk -F, '$4 == "Active" {print}'

Or even

awk -F, '$4 == "Active"' file

EDIT: Added missing " ; thanks to vgersh99!

1 Like

Rudi, missing ":

awk -F, '$4 == "Active"' file
2 Likes