![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Go-Global for Unix V 2.2.4 | ahm2002 | UNIX for Dummies Questions & Answers | 1 | 12-18-2007 11:41 AM |
| dynamic global script | isingh786 | Shell Programming and Scripting | 2 | 01-24-2007 04:35 PM |
| Script to change UNIX password | kornshellmaven | Shell Programming and Scripting | 12 | 05-17-2006 09:58 AM |
| Change password script in Unix easily.. | zp523444 | UNIX for Advanced & Expert Users | 4 | 11-14-2005 11:14 AM |
| Urgent !!! - Script to Change passwords in unix | tofani | SUN Solaris | 2 | 09-16-2003 03:58 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Unix script to do a global change
I want to write a script to go into a unix directory and recursively change all the instances of a word in every file in every directory and sub directory.
Here's where I am now: I can execute find . -print | xargs grep "my_word" to recuresively return all the files with my_word in it. So, now I know which files contain my_word, and now I need to figure out how to write a script and go in and change every occurance of my_word to new_word. Can anyone help? |
| Forum Sponsor | ||
|
|
|
|||
|
I wanted to thank those who responded to my question. I ended up using a derivation of this solution:
------------- find . -type f |\ while read file do { rm "${file}"; sed -e '/my_word/s/my_word/new_word/g' > "${file}"; } < "${file}" done ----------- |
|||
| Google The UNIX and Linux Forums |