1752623 Members
4378 Online
108788 Solutions
New Discussion юеВ

Re: using tr utility

 
SOLVED
Go to solution
Sharvil Desai
Frequent Advisor

using tr utility

Hi,
I need to replace all tab characters in the file with a single space. How do I do it?
I tried,
tr -s "/t" " " I know this isn't right, can someone please tell me how to accomplish this? Thank you :-)
"help!"
5 REPLIES 5
Sharvil Desai
Frequent Advisor

Re: using tr utility

:-) Never mind it works now!
I used "\t" and it did what I needed it to do. However, it is hard to differentiate tabs and whitespaces. Is there any easy way to look at the file and determine whether the blank space is a tab or multiple whitespaces? Thank you!
"help!"
Stuart Browne
Honored Contributor
Solution

Re: using tr utility

You could always try 'cat -t ', to show Tab characters as '^I'.

If using Vi, you can use the command ':set list'.

Failing either of those, you've always get 'hexdump' :)
One long-haired git at your service...
Sharvil Desai
Frequent Advisor

Re: using tr utility

Thanks for additional useful info.
"help!"
Graham Cameron_1
Honored Contributor

Re: using tr utility

Sharvil
I know you're sorted now but you may like to look at the "expand" command, which is specifically to remove tabs.
--
expand -t 1 view.txt will do what you want.
--
-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Sharvil Desai
Frequent Advisor

Re: using tr utility

Great! I learned something new! Thnx for your feedback, Graham!
"help!"