I'm migrating a site from one server to another. The site has several hundred CGI scripts that scatter around in different subdirectories. I need to change the shebang line in all the scripts. Instead of manually edit all the scripts, is there is UNIX/Linux command or utility that can make my life easier. If yes, can you give me specific instructions? Thanks!
Here is my disclaimer: This might not work. It has not been tested. If it doesn't work, it might erase files. Don't run it before backing up all of the files you need. I'm not responsible for any damage this does to your system. In fact, I'm not even recommending that you use this command at all--the symlink idea is much safer and better in the long run. How's that for confidence in my work?
But if you do end up using it, it would probably be a good idea to run it as a non-privlidged user just to be on the safe side. Be sure to set the target directory correctly in the command.
Matt Lightner - http://www.mattlightner.com/
- First initial to the last name at the mail service provided by the world's largest search engine
- Founder and CEO (Former) Site5.com, sold in 2008
- Really honestly wants to be a good WHT citizen but can never remember all the correct etiquette. Mods, sorry in advance
Hmm...that looks like it should work, but lets make it even easier. If you don't have any other reference to /local in your scripts, then we don't really need to replace all that text, we just need to remove the /local, right?
Try this (I just tested it on my system and it worked):
Originally posted by Bee Based on the info you guys provided, I did the following but it didn't work. I need it to find/replace recursively from the /home directory down. What am I missing? Thanks for all your help.
You're welcome. Sorry you didn't get it to work though.
Whaddaya mean, "you guys". That wasn't what I posted. My solution was the below CODE and doesn't have all of those unnecessary characters in the regex. Did you try it? Did you try it thru telnet or in a perl file? If you tried it in a file, you would need to add
### START OF CODE
find /directory/path -type f | xargs perl -pi -e 's/\/local//g';
### END OF CODE
BTW, I purposely left ".bak" out of my suggestion, because I felt confident that it would not mess up your files, and I didn't see the need for making .bak backup files and then having to remove them.
Datawire: Looks like the other thread is a bit different. It's about replacing file names as in $_. This one is about replacing text within files.