Issue
I have a text file with 1000 records in it, say 1..2..3...1000. In Unix, how do i delete only the records 2,13,20,500, 780 and 1000.
Please help me with the syntax.
Thanks.
Solution
Your question seems to have changed. Originally you wanted to delete lines by their line number, but now it seems you want to delete lines containing a certain pattern.
There are a couple of options for deleting lines containing GroupKey
. First, with sed
:
sed '/GroupKey/d' yourFile > newFile
Or, secondly with grep
and a negative/inverted search:
grep -v "GroupKey" yourFile > newFile
Or, with awk
:
awk '!/GroupKey/' yourFile
Answered By - Mark Setchell