akh22
akh22

Reputation: 701

How to make GNU sed remove certain characters from a line

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

Upvotes: 0

Views: 78

Answers (2)

potong
potong

Reputation: 58371

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.

Upvotes: 0

sseLtaH
sseLtaH

Reputation: 11207

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

Upvotes: 1

Related Questions