Help - Search - Members - Calendar
Full Version: hrmmm shell script or vi commands?
linux-noob.com/forums > Linux Noob > Tips and Tricks
tek-69
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
hijinks
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
tek-69
hows it know we wanna change the word heh in the example? unsure.gif
hijinks
opps damnit.. i meant cat smile.gif not heh my bad
tek-69
thanks for the info man that really helps speed things up.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.