Home > other >  How to make GNU sed remove certain characters from a line
How to make GNU sed remove certain characters from a line

Time:08-04

I have a following line;

�5=?�@A00165:69:HKJ3YDMXX:1:1101:16812:7341 1:N:0:TCTTAAAG

and would like to remove characters, �5=?� in front of @. So the desired output looks as follows;

@A00165:69:HKJ3YDMXX:1:1101:16812:7341 1:N:0:TCTTAAAG

I used gnu sed (v4.8)with a following argument;

sed "s/.*@/@/"' 

but this did not remove �5=?� thought it worked in the GNU sed live editor. At this point, I really appreciate any help on this.

My system is 3.10.0-1160.71.1.el7.x86_64

CodePudding user response:

Using sed, remove everything up to the first occurance of @

$ sed 's/^[^@]*//' input_file
@A00165:69:HKJ3YDMXX:1:1101:16812:7341 1:N:0:TCTTAAAG

CodePudding user response:

This might work for you (GNU sed):

sed -E 's/(\o357\o277\o275)5=\?\1//g' file

This removes all occurrences of �5=?�.

N.B. To translate the octal strings use sed -n l file to display the file as is. The triplets \357\277\275 can be matched in the LHS of the substitute command by using \o357\o277\o275.

  • Related