![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| 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 03:41 PM |
| dynamic global script | isingh786 | Shell Programming and Scripting | 2 | 01-24-2007 08:35 PM |
| Script to change UNIX password | kornshellmaven | Shell Programming and Scripting | 12 | 05-17-2006 12:58 PM |
| Change password script in Unix easily.. | zp523444 | UNIX for Advanced & Expert Users | 4 | 11-14-2005 03:14 PM |
| Urgent !!! - Script to Change passwords in unix | tofani | SUN Solaris | 2 | 09-16-2003 06:58 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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? |
|
||||
|
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 ----------- |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|