recusive ls/search/replace function!!
Johnathan Bailes
johnathan.bailes at gmail.com
Wed Apr 27 00:22:27 UTC 2005
On 4/26/05, bruce <bedouglas at earthlink.net> wrote:
>
>
> > hi..
> >
> > can't figure this out. it's basic.. how can i do a find of all files in
> > underlying recursive dirs. also, how can i do a search/replace of txt in
> all
> > files that match a certain extension..
> >
> > ie, how do i find all files that end in 'int' in the underlying dirs...
> > or, how do i replace "foo' with 'dog' in all underlying dirs that end in
> > 'ddf'..
> >
> > i can see that 'ls -R * can/should get me all underlying files... but...
> >
> > i can also see that find . -name "*.int" would work to find the files...
> but
> > i'm not sure how to get the rest.
>
> You're probably after something like:
>
> $ find . -name '*.int' -exec sed -i -e 's/foo/dog/g' {} \;
>
> Paul.
> --
> Paul Howarth <paul at city-fan.org>
>
> thanks...
>
> any idea how to delete all files in a subdirectory with a certain
> extension...??
>
> -bruce
>
> --
> fedora-list mailing list
> fedora-list at redhat.com
> To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
>
How to delete all files in a subdirectory with a certain extension:
find /home/enduser/stuff/* -name "*.blah" -print
Run that first before running the next command to make sure the output
is what you expect.
Then and only then you run:
find /home/enduser/stuff/* -name "*.blah" -exec rm {} \;
or even safer
find /home/enduser/stuff/* -name "*.blah -exec rm -i {} \;
But that last command will prompt you for every single file and ask if
you really want to delete it.
More information about the users
mailing list