I have a text file,of 100 lines,i need to move line 40 to line 39(refer to position) How to do this with sed? I tried
sed '40 m 39' file
and
sed '40,39m' file
but give me error. Thanks
I have a text file,of 100 lines,i need to move line 40 to line 39(refer to position) How to do this with sed? I tried
sed '40 m 39' file
and
sed '40,39m' file
but give me error. Thanks
With GNU sed:
seq 1 43 | sed -e '39{h;d};40{p;g}' | tail -n 8
Output:
36 37 38 40 39 41 42 43
Try:
$ sed -e '39N;s/\(.*\)\n\(.*\)/\2\
\1/' file
sed -e '39N;s/\(.*\)\n\(.*\)/\2\n\1/' file
– cuonglm
Mar 22 '15 at 18:22