One-line global string replace in all files with sed (or awk?)
Jerry McAllister
jerrymc at clunix.cl.msu.edu
Wed Jan 26 07:56:50 PST 2005
>
> A few years ago, I'm sure I came across a one-line way of replacing
> every occurence of one string with another in an entire directory of
> files (potentially including all subdirectories as well). I think it
> used sed or awk. Now I can't find it. The examples on the Web are all
> multiline scripts or programs, but I'm sure I saw a way to do it all on
> just one line.
>
> Can anyone tell me how to do this?
Check out tr(1).
There are other ways, but for basic stuff, it is easy and fast.
I use it often for stripping out the extra CRs from MSDOS files.
Something like:
tr -d "\r" < dirtydos > cleanunix
does the trick.
But it will do replaces and pretty much anything. Its syntax is
a little different that regular expressions type (maybe a little
easier actually) so read the man page.
////jerry
> --
> Anthony
>
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>
More information about the freebsd-questions
mailing list