Skip to main content
Became Hot Network Question
Tweeted twitter.com/StackUnix/status/1159932505878872064
deleted 1 character in body
Source Link
nicg
  • 91
  • 1
  • 5

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
STACKSTAC
asd
as

Output:

STAC
asd
as

I have this code sed -ni "s/^.*STAC//d" myfile

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
STACK
asd
as

Output:

STAC
asd
as

I have this code sed -ni "s/^.*STAC//d" myfile

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

deleted 24 characters in body; edited tags
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162

I want to delete all the words before a pattern, this is for example, i: I want to delete all the words before "STAC"STAC.

Input:

Input:

asd
asdd
asddd
STACK
asd
as
 
Output:

Output:

STAC
asd
as

Actually, iI have this code sed -ni "s/^.*STAC//d" myfile

Thanks

I want to delete all the words before a pattern, this is for example, i want to delete all the words before "STAC":

Input:

asd
asdd
asddd
STACK
asd
as
 
Output:
STAC
asd
as

Actually, i have this code sed -ni "s/^.*STAC//d" myfile

Thanks

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
STACK
asd
as

Output:

STAC
asd
as

I have this code sed -ni "s/^.*STAC//d" myfile

Source Link
nicg
  • 91
  • 1
  • 5

sed delete all the words before a match

I want to delete all the words before a pattern, this is for example, i want to delete all the words before "STAC":

Input:

asd
asdd
asddd
STACK
asd
as

Output:
STAC
asd
as

Actually, i have this code sed -ni "s/^.*STAC//d" myfile

Thanks