Vi editor ?

Tags
shell scripts

 
Thread Tools Search this Thread
# 1  
Old 06-27-2005
Vi editor ?

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
# 2  
Old 06-27-2005
Quote:
Originally Posted by billy5
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\/
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/

;
# 3  
Old 06-27-2005
Thank you very much Smilie.
All the best.

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
What editor does everyone use? yongho Open Source 401 5 Days Ago 05:58 AM
How can I do this in VI editor? kraljic Shell Programming and Scripting 9 03-09-2013 10:47 PM
Help with vi editor gonchusirsa UNIX for Dummies Questions & Answers 1 01-19-2013 12:55 AM
Vi Editor Sudip_Felipemas UNIX for Dummies Questions & Answers 6 02-02-2012 08:01 AM
Help in Vi Editor gameboy87 Programming 2 09-16-2011 11:05 PM
Vi editor jazz Programming 2 05-08-2009 09:46 AM
Epic Editor was not able to obtain a license for your use. Feature Epic Editor :Licen durgaprasadr13 Solaris 1 10-13-2008 08:39 AM
set EDITOR=vi -> default editor not setting for cron tab aarora_98 Shell Programming and Scripting 6 09-13-2008 03:01 AM
Pasting text in VI editor from a different editor harishmitty UNIX for Dummies Questions & Answers 10 09-10-2008 07:22 PM
VI Editor doyindayo UNIX and Linux Applications 3 08-26-2008 09:14 AM
Which editor to use? Nafanja UNIX for Dummies Questions & Answers 5 11-29-2007 12:58 PM
vi editor MaxK UNIX for Dummies Questions & Answers 2 10-18-2006 11:42 PM
vi editor diptiman Solaris 15 05-21-2006 12:55 PM
best editor annemar UNIX Desktop Questions & Answers 1 10-10-2005 01:05 PM
vi editor alain123456 UNIX for Advanced & Expert Users 3 07-21-2005 12:07 PM