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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Its everybodies friend: Vi

Status
Not open for further replies.
Jun 28, 2002
64
GB
Hi guys,

I am trying to make a shell script in vi, there is loads of lines and I want this perl statement to be at the begining of each line. I can get the word 'perl' to work but if there is a space after the word 'perl'it doesnt work at all.

%s/\(.*\)/perl -pi -e"s/string1/string2/g"

I have tried putting all sorts of quotes around it

%s/\(.*\)/'perl -pi -e"s/string1/string2/g"'

This doesnt work either, any ideas ?



 
Hello,
At first you have to use a \ with the last two / and then add a & to copy the line

Here is my solution :
%s/.*/perl -e"s\/string1\/string2\/g" &


@+
Lolo
 
Or use a different delimeter and substitute the binginning of the line using the ^ meta-character

%s#^#perl -pi -e"s/string1/string2/g"#

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top