sed removal

Hi I am trying to delete lines in a file that consist only "GETaboutUsCSS" but it should not remove "GETaboutUsCSS-0" "GETaboutUsCSS-1".
could some one help me in this.

input file:
GETaboutUsCSS
GETaboutUsCSS-0
GETaboutUsCSS-1
output file:
GETaboutUsCSS-0
GETaboutUsCSS-1

i tried this

 sed -i '/GETaboutUsCSS/d' file

but it is deleting all the lines.
please help me in this.

Maybe try adding the "end of line" directive to your REGEX?

You can use $ to match the end of your REGEX, if you want to try.

1 Like

Have a ^ anchor for the beginning of the line, and a $ anchor for the end of the line:

sed -i '/^GETaboutUsCSS$/d' file
1 Like

it worked

this is not working ..when i a input file like below,

2020-02-29 11:28:19.790,82,GETAboutusCSS-0,307,Temporary Redirect,10.152.194.47:2016-SequenceLength 1-50,,true,,653,3,4,http://bus00gcw.us.oracle.com:8181/ccstoreui/v1/pages/css/home?occsite=siteUS,82,0
2020-02-29 11:28:19.874,15,GETAboutusCSS-1,200,OK,10.152.194.47:2016-SequenceLength 1-50,text,true,,689,3,4,http://bus00gcw.us.oracle.com:8181/file/v377120732786334646/css/homePageLayout.css?occsite=siteUS,15,0
2020-02-29 11:28:19.953,76,GETAboutusCSS,200,OK,10.152.194.47:2016-SequenceLength 1-49,text,true,,1342,3,4,http://bus00gcw.us.oracle.com:8181/file/v377120732786334646/css/homePageLayout.css?occsite=siteUS,35,0

--- Post updated at 06:32 PM ---

could you please help me when there is a input file like this.

2020-02-29 11:28:19.790,82,GETAboutusCSS-0,307,Temporary Redirect,10.152.194.47:2016-SequenceLength 1-50,,true,,653,3,4,http://bus00gcw.us.oracle.com:8181/ccstoreui/v1/pages/css/home?occsite=siteUS,82,0
2020-02-29 11:28:19.874,15,GETAboutusCSS-1,200,OK,10.152.194.47:2016-SequenceLength 1-50,text,true,,689,3,4,http://bus00gcw.us.oracle.com:8181/file/v377120732786334646/css/homePageLayout.css?occsite=siteUS,15,0
2020-02-29 11:28:19.953,76,GETAboutusCSS,200,OK,10.152.194.47:2016-SequenceLength 1-49,text,true,,1342,3,4,http://bus00gcw.us.oracle.com:8181/file/v377120732786334646/css/homePageLayout.css?occsite=siteUS,35,0

Try to apply what you learned in this thread:

sed -i '/^GETaboutUsCSS$/d' file

translates to

sed -i '/,GETaboutUsCSS,/d' file

GNU sed and maybe BSD sed support ExtendedRE with a - r or -E option.
Then you can do a universal search:

sed -i -r '/(^|,)GETaboutUsCSS(,|$)/d' file

At the left side there must be either the beginning of the line or a comma.
And at the right side there must be either a comma or the end of the line.

Unfortunately you cannot use a character set here.

sed -i '/[^,]GETaboutUsCSS[,$]/d' file

Because ^ and $ are only markers not characters.

1 Like

yes this lines has delimiter ","... but some lines has different delimiter like "=" then it wont work right
so i thought of not using delimiter comma in search string..
ok fine ...let me go thru this...
and will take care rest of the delimiters.