user266095
user266095

Reputation: 15

manipulation of text by sed command

I a file containing the genome ids following NZ_FLAT01000030.1_173 I need to manipulate those ids like this one: NZ_FLAT01000030.1 I tried some but didn't give me the exact thing.

sed 's/_/\t/' output : NZ FLAT01000030.1_173
sed -r 's/_//' output: NZFLAT01000030.1_173
sed -r 's/_//g' output: NZFLAT01000030.1173

How can I do that by using sed command?

Upvotes: 1

Views: 38

Answers (2)

Ed Morton
Ed Morton

Reputation: 203532

$ echo 'NZ_FLAT01000030.1_173' | sed 's/_[^_]*$//'
NZ_FLAT01000030.1

Upvotes: 0

jspcal
jspcal

Reputation: 51904

Are you trying to remove the undesrscore and the digits following it?

echo 'NZ_FLAT01000030.1_173' | sed -E 's/_[0-9]+//g'

NZ_FLAT01000030.1

Upvotes: 1

Related Questions