[CentOS] replace multiple string

2011-09-23 Thread madu...@gmail.com
Hi I would like to use a bash script that searches files and subdirectories name in a directory /var/ww/html/web for a specific string, and when it finds the search string, replaces the string (old1) with new string (new1), and so on old2 with new2 oldn with newn. replace_string.sh

Re: [CentOS] replace multiple string

2011-09-23 Thread m . roth
madu...@gmail.com wrote: I would like to use a bash script that searches files and subdirectories name in a directory /var/ww/html/web for a specific string, and when it finds the search string, replaces the string (old1) with new string (new1), and so on old2 with new2 oldn with newn.

Re: [CentOS] replace multiple string

2011-09-23 Thread madu...@gmail.com
-type f ?? the string could be a name of file name or subdirectory name Thanks pons On Fri, Sep 23, 2011 at 8:51 PM, m.r...@5-cent.us wrote: madu...@gmail.com wrote: I would like to use a bash script that searches files and subdirectories name in a directory /var/ww/html/web for a specific

Re: [CentOS] replace multiple string

2011-09-23 Thread m . roth
madu...@gmail.com wrote: -type f ?? the string could be a name of file name or subdirectory name No, it can't. You are *not* going to edit directory names this way, and should not. mark Thanks pons On Fri, Sep 23, 2011 at 8:51 PM, m.r...@5-cent.us wrote: madu...@gmail.com wrote:

Re: [CentOS] replace multiple string

2011-09-23 Thread m . roth
madu...@gmail.com wrote: -type f ?? the string could be a name of file name or subdirectory name I hate webmail. After I hit send and while it was thinking about going, I realized another question: are you trying to rename files? mark Thanks pons On Fri, Sep 23, 2011 at 8:51

Re: [CentOS] replace multiple string

2011-09-23 Thread madu...@gmail.com
yes files and directories too .. pons On Fri, Sep 23, 2011 at 9:08 PM, m.r...@5-cent.us wrote: madu...@gmail.com wrote: -type f ?? the string could be a name of file name or subdirectory name I hate webmail. After I hit send and while it was thinking about going, I realized another

Re: [CentOS] replace multiple string

2011-09-23 Thread m . roth
madu...@gmail.com wrote: pons On Fri, Sep 23, 2011 at 9:08 PM, m.r...@5-cent.us wrote: madu...@gmail.com wrote: -type f ?? the string could be a name of file name or subdirectory name snip I realized another question: are you trying to rename files? yes files and directories too .. Then

Re: [CentOS] replace multiple string

2011-09-23 Thread Les Mikesell
On Fri, Sep 23, 2011 at 1:21 PM, m.r...@5-cent.us wrote: I realized another question: are you trying to rename files? yes files and directories too .. Then different commands - sed for the files, mv for the directories. This begins to look like a perl script. Either way, it's probably a

Re: [CentOS] replace multiple string

2011-09-23 Thread m . roth
Les Mikesell wrote: On Fri, Sep 23, 2011 at 1:21 PM, m.r...@5-cent.us wrote: I realized another question: are you trying to rename files? yes files and directories too .. Then different commands - sed for the files, mv for the directories. This begins to look like a perl script. Either

Re: [CentOS] replace multiple string

2011-09-23 Thread madu...@gmail.com
I am planning to have this in 2 stages first -type fthen -type d pons On Fri, Sep 23, 2011 at 11:15 PM, m.r...@5-cent.us wrote: Les Mikesell wrote: On Fri, Sep 23, 2011 at 1:21 PM,  m.r...@5-cent.us wrote: I realized another question: are you trying to rename files? yes files and

Re: [CentOS] replace multiple string

2011-09-23 Thread John R Pierce
On 09/23/11 1:51 PM, madu...@gmail.com wrote: I am planning to have this in 2 stages first -type fthen -type d you likely should use the -depth option that says descend first, even if you do the files seperately if you use -depth, you don't have to do it in two phases. -- john

Re: [CentOS] replace multiple string

2011-09-23 Thread Thomas Johansson
On 2011-09-23 19:47, madu...@gmail.com wrote: Hi I would like to use a bash script that searches files and subdirectories name in a directory /var/ww/html/web for a specific string, and when it finds the search string, replaces the string (old1) with new string (new1), and so on old2 with

Re: [CentOS] replace multiple string

2011-09-23 Thread Bart Schaefer
On Fri, Sep 23, 2011 at 10:47 AM, madu...@gmail.com madu...@gmail.com wrote: I would like to use a bash script that searches files and subdirectories name in a directory /var/ww/html/web for a specific string, and when it finds the search string, replaces the string (old1) with new string

Re: [CentOS] replace multiple string

2011-09-23 Thread John R Pierce
how about... find . -depth -execdir mv \{} ${\{}/old/new} \; I do highly recommend test-running this with a echo in front of the mv command. I didn't test it. -- john r pierceN 37, W 122 santa cruz ca mid-left coast