Re: Mass find and replace with / as one item that needs to be replaced.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 01 January 2005 16:07, Jeffrey Strain wrote:
> need to find and replace a path in many files.  I am wondering how to do
> this.
>
> I tried using perl -pi -e, but do not know how to replace the path
> without messing up the command due to the / in the path.  Any assistance
> would be greatly appreciated.
If I understand this correctly you have a number of files which contain text 
similar to
/path/to/a/directory
and you want to replace this text with something like
/a/different/directory

personally I lean towards sed on this one.
the / as a pattern separator is not set in stone - you can use almost anything 
you want (at least with sed, you can. dunno about perl).
so a command similar to

sed -i.orig 's,/path/to/a/directory,/a/different/directory,g' myfilename

will do the actual replacement for you.
sed now does in-place editing.
the -i.orig will backup the original version of myfilename as myfilename.orig

all you need to do now is give it the correct files to work with.
-- 
Stuart Sears RHCE, RHCX
I have found little that is good about human beings.  In my experience
most of them are trash.
		-- Sigmund Freud

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux