I have a file a.txt having content like
deepak
ram
sham
deepram
sita
kumar
I Want to delete the first line containing "deep" ...
I tried using...
grep -i 'deep' a.txt
It gives me 2 rows...I want to delete the first one..
+ need to know the command to delete the line from a file by line number.
$ sed '1d' filename
Here "1" is the line number .. u can change as your wish..
do you know the answer of my first question?
$ grep -i 'deep' filename | sed '1d'
1 Like
$nawk '{if($0~/^deep/ && count==0){count++}else{print $0;}}' input.txt > output.txt
ram
sham
deepram
sita
kumar
$cat input.txt
deepak
ram
sham
deepram
sita
kumar
Another approach:
awk '/deep/ && !c++{next}1' file