Unix Technical Forum

Replace tab character with spaces

This is a discussion on Replace tab character with spaces within the AIX Operating System forums, part of the Unix Operating Systems category; --> What command can be used for replacing the tab character with spaces? Where the number of spaces is equivalent ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 12:34 PM
David Groff
 
Posts: n/a
Default Replace tab character with spaces

What command can be used for replacing the tab character with
spaces? Where the number of spaces is equivalent to the number of
spaces in a tab. I've tried expand, but this doesn't seem to work.
I also tried using tr a while ago, but when I tried to compile fortran
code the tab characters are not removed. Perhaps I am not using tr
correctly. Any suggestions would be appreciated.
Thank You
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 12:34 PM
Joachim Gann
 
Posts: n/a
Default Re: Replace tab character with spaces

col -x should do the trick:

$ /bin/echo a\\tb|od -c
0000000 a \t b \n
0000004
$ /bin/echo a\\tb|col -x|od -c
0000000 a b \n
0000012

Regards
Joachim Gann

On 10 Apr., 14:58, David Groff <david.gr...@noaa.gov> wrote:
> What command can be used for replacing the tab character with
> spaces? Where the number of spaces is equivalent to the number of
> spaces in a tab. I've tried expand, but this doesn't seem to work.
> I also tried using tr a while ago, but when I tried to compile fortran
> code the tab characters are not removed. Perhaps I am not using tr
> correctly. Any suggestions would be appreciated.
> Thank You



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 12:34 PM
Ian Northeast
 
Posts: n/a
Default Re: Replace tab character with spaces

On Tue, 10 Apr 2007 08:58:47 -0400, David Groff wrote:

> What command can be used for replacing the tab character with spaces?
> Where the number of spaces is equivalent to the number of spaces in a tab.
> I've tried expand, but this doesn't seem to work. I also tried using tr a
> while ago, but when I tried to compile fortran code the tab characters are
> not removed. Perhaps I am not using tr correctly. Any suggestions would be
> appreciated. Thank You


Expand should work. What's going wrong when you try it? What AIX version
and manintenance level do you have?

I don't think tr will do what you want, it replaces characters with single
characters, not strings.

Sed should do: sed -e "s/<tab>/<however many spaces>/g" - except that this
will replace each tab with the same number of spaces, it won't column
align.

Also there's untab but it doesn't do anything expand won't and is not very
flexible (e.g. tab size fixed at 8 spaces).

Regards, Ian

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:05 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com