Linux-Noob Forums
hrmmm shell script or vi commands? - Printable Version

+- Linux-Noob Forums (https://www.linux-noob.com/forums)
+-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html)
+--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html)
+--- Thread: hrmmm shell script or vi commands? (/thread-3486.html)



hrmmm shell script or vi commands? - tek-69 - 2004-04-07


sup guys,

I have a directory full of c files header files and whatnot. What i want to do is go into all the files

in the directory and change specific strings to other specific strings, all at once. should i be looking up

vi commands for this task or should i be reading up on shell commands and scripting? Any advice would be of great help.

Thanks,

Tek




hrmmm shell script or vi commands? - hijinks - 2004-04-07


if you want to change the string "cat" to "Jy Rules" do this

 

to create backups of your header files just in case

 

perl -pi.bak -e 's/cat/Jy Rules/g' *.h

 

if you don't need backups

 

perl -pi -e 's/cat/Jy Rules/g' *.h




hrmmm shell script or vi commands? - tek-69 - 2004-04-07

hows it know we wanna change the word heh in the example? :/



hrmmm shell script or vi commands? - hijinks - 2004-04-07

opps damnit.. i meant cat :)not heh my bad



hrmmm shell script or vi commands? - tek-69 - 2004-04-07

thanks for the info man that really helps speed things up.