I want to insert text before the first line of a file. I want to use sed and command
sed -i '1s/^/line_to_be_added\n/' file.txt
works fine, but when I want to add directory path and use slashes in command I get an error sed: -e expression #1, char 9: unknown option to
s'. My command sed -i '1s//var/log/firstlogs/logs/first.json\n/' file.txt
How to escape slashes in this case?
Asked
Active
Viewed 85 times
0

mila002
- 327
- 3
- 14
-
`sed -i '1s/^/\/var\/log\/firstlogs\/logs\/first.json\n/' file.txt` – Sonny Mar 05 '19 at 10:22
-
Thank You, works great! – mila002 Mar 05 '19 at 10:36