Separate lines from text file

I have a text file with lot of rows like..
Action & Adventure|2012: Supernova NR|2009-11-01 00:01:00|2010-05-01 23:59:00|Active|3
Action & Adventure|50 Dead Men Walking|2010-01-05 00:01:00|2010-06-30 23:59:00|Active|3
Action & Adventure|Afterwards|2009-11-26 00:01:00|2010-03-26 23:59:00|Deactivated|3

the 5th column can have different statuses.i want to extract all the rows from the file having only "Active" in the 5th column.
pls.help.

Thanks in advance.

awk -F '|' '$5 ~ /^Active$/ {print $0}' filename

May be I should do some explaining too :slight_smile:

awk is a unix filter.
-F : field separator, in your case its the character '|'
the awk script says that if the $5 (5th field) ~ (matches) the pattern /^Active$/ (^ and $ mean begins with and ends with respectively), then print $0, i.e the entire line.

Lemme know if that helped.

Thanks for the reply.

i tried like this but a.txt is empty

 
awk -F"|" '$5 ~ /^Active$/ {print $0}' FinalVHO.txt>a.txt

is there anything wrong with it?

well i copied the text from your post verbatim and ran the same line of code I provided and it worked. How big is your input file? Are there spaces/tabs around the word Active in the 5th column? Is there atleast one line in the file that has Active in the 5th column?