I want to delete all the words before a pattern for example: I want to delete all the words before STAC
.
Input:
asd
asdd
asddd
STAC
asd
as
Output:
STAC
asd
as
I have this code sed -ni "s/^.*STAC//d" myfile
sedtext processing
I want to delete all the words before a pattern for example: I want to delete all the words before STAC
.
Input:
asd
asdd
asddd
STAC
asd
as
Output:
STAC
asd
as
I have this code sed -ni "s/^.*STAC//d" myfile
Best Answer
sed
works linewise, that's why your try will not work.So how to do it with
sed
? Define an address range, starting from theSTAC
line (/^STAC$/
) to the end of the file ($
). Those should be printed, so everything else (!
) should getd
eleted: