[CLUE-Tech] find & replace on a tree of files
David L. Willson
DLWillson at TheGeek.NU
Mon Nov 1 15:13:43 MST 2004
Now, if only I could mod that so that it clears everything but one newline
between <head> and <title> and everything but one newline between </title> and
</head>, I'd be a happy dude. It seems that I cannot find the right set of
RegEx's to do this... Help?
____________________
David L. Willson
tel://720.333.LANS
Linux+ A+ Net+ MCSE
Quoting "David L. Willson" <DLWillson at thegeek.nu>:
> Never let it be said that I missed an opportunity to show publically that I
> am
> the slow kid...
>
> I just figgered out how to do this thing, and it seemed cool to me, so I'm
> sending it on to you.
>
> The following one-liner is polluted with whacks to show you that it really
> should be all-on-one-line. Actually, you can use it all-on-one-line, or with
> a
> whack at the end of each sub-line, like you see here.
>
> What it does is the sub-tree beginning here (.), looking for files matching
> the
> spec '*.hay', which could be any spec. The one I use most often is, sadly,
> '*.asp'. Then, for each matching file, it finds each instance of
> 'old_needle'
> and replaces that text with 'new_needle', globally.
>
> Incidentally, don't mess with the space-whack-semicolon at the end of the
> command, it matters a lot.
>
> find . \
> -iname '*.hay' \
> -exec \
> sed -e s/old_needle/new_needle/g -i.backup {} \;
> ____________________
> David L. Willson
> tel://720.333.LANS
> Linux+ A+ Net+ MCSE
>
>
>
>
>
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
> _______________________________________________
> CLUE-Tech mailing list
> Post messages to: CLUE-Tech at clue.denver.co.us
> Unsubscribe or manage your options:
> http://clue.denver.co.us/mailman/listinfo/clue-tech
>
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
More information about the clue-tech
mailing list