Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crazy Vi command's

Status
Not open for further replies.
Jun 28, 2002
64
GB
Calling all you gurus out there!

I have a list of files that I need to make backups of,
about 50 files. I have been trying to use the :map command in vi to insert a cp at the front of each line, then copy each line (with out the cp) add it to the same line and then add a .bak ext to each file

so the file looks like:
/usr/informix/etc/onconfig
/usr/informix/etc/sqlhosts

I want it it to look like :
cp /usr/informix/etc/onconfig /usr/informix/etc/onconfig.bak
cp /usr/informix/etc/sqlhosts /usr/informix/etc/sqlhosts.bak

I am using the map command to insert the cp:

:map # I cp ^[ k I cp
is there an easer way or am I barking up the wrong tree ?! , I am saving myself from RSI. lol.

Paul.
 
I'm not familiar with the map command, but you could use search and replace:

[tt]:%s/\(.*\)/cp \1 \1.bak/[/tt]

\1 is replaced with everything between \( and \) in the matching string.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top