billy5
1
Hello everybody,
My question is: how to add /tmp/work at the end of line in vi editor.
my file looks like:
cp file1
cp file2
cp file3
****
I need to add " /tmp/work" at the end of each line.
I tried this
:%s/$/" /tmp/work"
and this
:%s/$/\ /tmp/work\/
but it does not work.
Please help.
Thank you
There are a couple of ways to fix this. First, remember that the / between tmp and work is seen as a separator. So you can use
:%s/$/ \/tmp\/work\//
or you could change the separator like this:
"%s:$: /tmp/work/:
Both of these options will change the file to
cp file1 /tmp/work/
cp file2 /tmp/work/
cp file3 /tmp/work/
;
billy5
3
Thank you very much :).
All the best.