Tuesday, August 21, 2007

Remove Tabs From a File -- UNIX

Occasionally, you might want to remove tabs from a file. This can be accomplished with the expand command. Here's an easy way of doing that.

View tabs (^I)
# cat -v -t esoftfile
esoft^Iesoft^Iesoft^Iesoft
esoft^Iesoft^Iesoft^Iesoft
esoft^Iesoft^Iesoft^Iesoft
esoft^Iesoft^Iesoft^Iesoft
esoft^Iesoft^Iesoft^Iesoft

View tabs (^I) removed and replaced with 5 spaces to stdout
# expand esoftfile | cat -v -t
esoft esoft esoft esoft
esoft esoft esoft esoft
esoft esoft esoft esoft
esoft esoft esoft esoft
esoft esoft esoft esoft

Tabs removed and output written to file
# expand esoftfile > esoftfile_notab

Verify tabs removed
# vi esoftfile_notab
esoft esoft esoft esoft$
esoft esoft esoft esoft$
esoft esoft esoft esoft$
esoft esoft esoft esoft$
esoft esoft esoft esoft$
~
~
~
:set list

2 comments:

Maher said...

Thnaks for sharing buddy

faisal said...

Thanks.