[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-user
Subject:    Re: [gentoo-user] OT: global search and replace
From:       Korthrun <korthrun () gmail ! com>
Date:       2004-09-09 2:50:19
Message-ID: 7d20977a04090819501ca7d532 () mail ! gmail ! com
[Download RAW message or body]

On Thu, 09 Sep 2004 12:33:59 +1000, Andrew Ross <aross@westnet.com.au> wrote:
> On Thu, 2004-09-09 at 11:42, Adam Carter wrote:
> > I need to run a script over all the docs in a htdocs folder (and sub
> > folders) to do a s/oldhostname/newhostname/g - my shell-fu is not up to
> > the task. How can i acheive this?
> 
> # Do the substitution on all files in current dir and subdirs
> ( find . ) | while read FILE
> do
>         sed -i 's/oldhostname/newhostname/g' "${FILE}"
> done
> 
> # Remove temp files created by sed
> for TMP_FILE in $(find . -empty -name 'sed*')
> do
>         rm ${TMP_FILE}
> done
> 
> Cheers
> 
> Andrew
> 
> 
> 
> 
> --
> gentoo-user@gentoo.org mailing list
> 
> 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

That looks cool. I always used a
find /some/path -criteria -exec perl -p -i -e 's/old/new/g' \;
or if I don't have wierd criteria, then just do it without the find.
Yay *nix for a billion ways to do something. Gotta love it.

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.2

iQA/AwUBQT/FIkJNESz0+cxBEQKmKgCgxPivDba7yewm1W9IG12CuB/ph/wAoPaM
knHRfHF+r8euTyqf/UUG+JAP
=qmfg
-----END PGP SIGNATURE-----
-- 
()  The ASCII Ribbon Campaign - against HTML Email,
/\  vCards, and proprietary formats.

--
gentoo-user@gentoo.org mailing list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic