Why is sed not recognizing \t as a tab?

sixtyfootersdude picture sixtyfootersdude · Apr 9, 2010 · Viewed 106.2k times · Source
sed "s/\(.*\)/\t\1/" $filename > $sedTmpFile && mv $sedTmpFile $filename

I am expecting this sed script to insert a tab in front of every line in $filename however it is not. For some reason it is inserting a t instead.

Answer

Mark Byers picture Mark Byers · Apr 9, 2010

Not all versions of sed understand \t. Just insert a literal tab instead (press Ctrl-V then Tab).