1834799 Members
2708 Online
110070 Solutions
New Discussion

Re: Tab stop conversion

 
SOLVED
Go to solution
cbres00
Frequent Advisor

Tab stop conversion

How do I convert tabs in a unix file to pipes?
Thanks in advance.
Cathy
Life is too short not to have fun every single day
6 REPLIES 6
Paddy_1
Valued Contributor

Re: Tab stop conversion

try the translate command called "tr"

tr "\t" "|" < infile > outfile

should solve your problem
The sufficiency of my merit is to know that my merit is NOT sufficient
James R. Ferguson
Acclaimed Contributor
Solution

Re: Tab stop conversion

Hi Cathy:

# sed sed 's//|/'g filename > filename.new

Note that instead of you should actually press the TAB key.

Regards!

...JRF...
cbres00
Frequent Advisor

Re: Tab stop conversion

Do I need an option? I get
"usage tr [ -cds ] ...."
message.
Life is too short not to have fun every single day
cbres00
Frequent Advisor

Re: Tab stop conversion

James' solution worked.
I didn't know I could use the tab key in a sed command. I thought I had to have an ascii character to translate. Very cool!
Thanks to all.
Cathy
Life is too short not to have fun every single day
Chris Vail
Honored Contributor

Re: Tab stop conversion

I have a different take on the tr command:
cat $INFILE|tr "\t" "|">>$OUTFILE

You could also use sed instead.


Chris
James R. Ferguson
Acclaimed Contributor

Re: Tab stop conversion

Hi (again) Cathy:

I might add that some 'sed' versions, like the GNU one (but not the HP-UX version) support '\t' to denote the TAB character.

Regards!

...JRF...