delete records from a file

I have a big file with "|" delimiter. I want to delete all the records that have 'abc' in the 2nd field. How can i do that? I am not abe to open it in VI that is why i need to do it from outside. Please suggest

awk -F'|' '$2 !~ /^abc$/' input_file.txt > output_file.txt

You can also use sed:

sed -e "/^[^\|]*\|abc\|/d" input_file.txt > output_file.txt

Thanks Klashxx

Can you explain what this means.

awk -F'|' '$2 !~ /^abc$/' input_file.txt > output_file.txt

does !~ means equal to? i thought its not equal to?

I think this means 'contains'

the '^abs' means is there the chars 'abc' at the beginning of $2 which is the field delimited by the character given in the '-F' flag to awk

Yes it's almost right. The operator "!~" means "does not match regexp".
The given regular expression matches exactly the word "abc" in the second field, so all the lines that does match this criteria are discarded.

But it won't match for a field value 'comabcpvt'.For that just use /abc/ in the regex.

With regards
Dileep Pattayath