sed \"s/\\(.*\\)/\\t\\1/\" $filename > $sedTmpFile && mv $sedTmpFile $filename
I am expecting this sed
script to insert a <
I used this on Mac:
sed -i '' $'$i\\\n\\\thello\n' filename
Used this link for reference
You don't need to use sed
to do a substitution when in actual fact, you just want to insert a tab in front of the line. Substitution for this case is an expensive operation as compared to just printing it out, especially when you are working with big files. Its easier to read too as its not regex.
eg using awk
awk '{print "\t"$0}' $filename > temp && mv temp $filename
TAB=$(printf '\t')
sed "s/${TAB}//g" input_file
It works for me on Red Hat, which will remove tabs from the input file.
Use $(echo '\t')
. You'll need quotes around the pattern.
Eg. To remove a tab:
sed "s/$(echo '\t')//"
Not all versions of sed
understand \t
. Just insert a literal tab instead (press Ctrl-V then Tab).