source file:
$cat test.file
aaa
bbb
ccc
I want to insert echo test> /var/tmp/file
into the second line, and the desired result is like this:
$ cat test.file
aaa
echo test > /var/tmp/file
bbb
ccc
I tried the following, but failed :(
$ sed -i "2 s/^/echo test > /var/tmp/file\n/" test.file
sed: -e expression #1, char 20: unknown option to `s'
$ sed -i "2 s/^/"echo test > /var/tmp/file"\n/" test.file
-bash: /var/tmp/file\n/: Is a directory