Hello All,
I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out.
My file is like this (<b> means one blank space, <t> means one tab space)-
$ cat file
NARESH<b><b><b>KUMAR<t><t>PRADHAN
<t><t>RAJESH<b><b><b><b><t><t>MITRA
The code should give the following output-
NARESH KUMAR PRADHAN
RAJESH MITRA
Note-
All the tab spaces got removed and treated as single blankspace.
All the blank spaces were removed and treated as single blank space.
Thanks,
Naresh
-All the tab spaces got removed and treated as single blankspace.
cat file | sed "s/\t\t*/ /g"
All the blank spaces were removed and treated as single blank space.
cat file | sed "s/ */ /g"
(look in "s/ */" are 2 spaces )
all:
cat file | sed "s/ / /g"| sed "s/\t\t / /g"
Thank you very much, yes it's working fine now. ONe thing to note here-
In AIX if we manually edit a file to include tabspaces, then these cmd may not work fine. One alternate cmd I found-
sed 's/'"$(echo '\011')"'//g;s/ //g' file
kshji
August 7, 2009, 11:18am
4
tr change all tabs => spaces.
tr -s is also nice cmd to compress every char*N.
cat file | tr "\t" " " | tr -s " "
cat file | tr "\011" " " | tr -s " "
cat file | tr $'\x09' " " | tr -s " "