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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
|
|