Replacing a special character with a tab delimiter

I have a file of 200 lines and 1 column and in each column the data is displayed as h: 158334782-158335532_Tb_052868_I8

what I want to do is whereever: either - or _ appears, it should be replaced with a tab section.

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

+3
source share
2 answers

With tr :

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

With sed :

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

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

where TAB is actually a tab

+1
source

All Articles