kkraja
1
hi every one
plz help me
i want to search for a line contains tabspace
This is a line The should be changed
see the above line is seperated with tab space i want to replace that tab space in to # as
This is a line#The should be changed
i have tried with
sed 's/[ \t]/#/g' file
but it is not working
plz help me to the tab space into #
Thanks in Advance
era
2
By "tab space" do you mean two characters, ASCII 9 and ASCII 32, or one character, just ASCII 9?
If the former, 's/ \t/#/' without the [ ]
If the latter, just 's/\t/#/' should work, although the command line you posted should also (accidentally) work.
If your sed doesn't understand \t then try entering a literal tab. In many shells, you type ctrl-v tab to get an actual tab into your command line.
kkraja
3
thanks for reply me,
i tried with both but it shows like this
This#is#a#line The#should#be#changed
plz help me....
era
4
Did you try using a literal tab instead of \t in the command?
Try also using tr:
tr '\011' <file >newfile
Like with sed there are different dialects of tr which understand slightly different syntax.
Or try Perl, which (blissfully) only exists in one implementation:
perl -pe 's/\t/#/' file
tr -s "\t" "#" <input_filename >output_filename