Reputation: 113
I use this command:
sed -i "10 i \t\t\ttime.sleep(0.1) " /home/test_file
to insert at line 10 a line like: <TAB><TAB><TAB>sleep(0.1)
But I got
t<TAB><TAB>sleep(0.1)...
Can you tell me how to get this result? thanks
PS. I use this command in an executable bash script.
Upvotes: 9
Views: 24762
Reputation: 504
Seems like '\t' means a TAB on my host(ubuntu18.04). Below is my command line when i want to insert a new line beginning with TAB at the line 50 inside the *.json files.
sed -i '50 i \t"opetin": true,' *.json
Upvotes: 0
Reputation: 1055
I believe the problem is with competition between the way that the shell and sed are expanding the meta-characters. I've tried tripling the first backslash character and that seems to work for me:
sed -i "i \\\t\t\ttime.sleep(0.1) " tmp.tmp
Upvotes: 34