Angelo
Angelo

Reputation: 5059

replacing special character by tab separation

I have a file of 200 rows and 1 column and in each column data appears as ch:158334782-158335532_Tb_052868_I8

what I want to do is whereever : or - or _ appears it should be replaced by a tab seperation.

the new file should look like this ch (tab) 158334782 (tab) 158335532 (tab) Tb (tab) 052868 (tab) I8

Any suggestions for a bash script...

Thank you in advance

Upvotes: 3

Views: 1304

Answers (2)

Prince John Wesley
Prince John Wesley

Reputation: 63698

With tr:

 tr ':\-_' '\t'  < infile > outfile

With sed:

 sed 's/[-_:]/\t/g' infile > outfile

Upvotes: 4

chrisdowney
chrisdowney

Reputation: 1558

sed -s 's/[-_]/TAB/'

where TAB is actually a tab

Upvotes: 1

Related Questions