Basically I have a file like:
junk
morejunk
somestring
bats
car
somestring
bats
car
somestring
bats
car
and I want to remove all of the junk
before the first occurrence of somestring
so the file looks like
somestring
bats
car
somestring
bats
car
somestring
bats
car
I followed the advice from this question to use sed -i '0,/somestring/,d' file.txt
but it deletes the line with the first occurrence of somestring
, when I want to keep that line as the first line.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…