Unix Shell - process alls files recursively in subdirectories

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2006 > process alls files recursively in subdirectories





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author process alls files recursively in subdirectories
donghuang.de@googlemail.com

2006-10-24, 7:21 am

hi folks,

i get an error using

for File in 'find . -name *.txt'
do
.....{code}
DONE

to prcocess alle files recursively.
grep: find . -name *.txt: No such file or directory

i tried type the find . -name *.txt
it did find all the .txt files.

I read some tutorials saying this should be work,
the {code} part works well to process the files in directory where the
code is.

what wrong is with the for loop?

btw. i am using CYGWIN. is that a problem?

anyone who has an idea?

thanks
dong

donghuang.de@googlemail.com

2006-10-24, 7:21 am

hi

i got it.
in stead of using `find . -name *.RPT -print`
i used 'find . -name *.RPT -print'
`` is not the "same" as ''

can someone give me a hint. what different are there?
thanks

On Oct 24, 10:00 am, donghuang...@googlemail.com wrote:
> hi folks,
>
> i get an error using
>
> for File in 'find . -name *.txt'
> do
> ....{code}
> DONE
>
> to prcocess alle files recursively.
> grep: find . -name *.txt: No such file or directory
>
> i tried type the find . -name *.txt
> it did find all the .txt files.
>
> I read some tutorials saying this should be work,
> the {code} part works well to process the files in directory where the
> code is.
>
> what wrong is with the for loop?
>
> btw. i am using CYGWIN. is that a problem?
>
> anyone who has an idea?
>
> thanks
> dong


Burton Samograd

2006-10-24, 1:17 pm

donghuang.de@googlemail.com writes:

> hi folks,
>
> i get an error using
>
> for File in 'find . -name *.txt'


You should be using backquotes around that:

`find . -name *.txt`

> do
> ....{code}
> DONE
>
> to prcocess alle files recursively.
> grep: find . -name *.txt: No such file or directory


Looks like it didn't expand the call since you used ' quotes. It
should work now. Don't forget to put quotes around "$File" in the
loop in case it has spaces in it.

> i tried type the find . -name *.txt
> it did find all the .txt files.
>
> I read some tutorials saying this should be work,
> the {code} part works well to process the files in directory where the
> code is.
>
> what wrong is with the for loop?


Find can do what you want by itself. Say you want to recursively grep
for something:

find -name '*.txt' -exec grep -H SOMETHING {} \;

{} is the current file name
end the line with \;

> btw. i am using CYGWIN. is that a problem?


Nope.

> anyone who has an idea?


Probably a few ;-) Hope this helps.



--
burton samograd kruhft .at. gmail
generative a/v artwork : http://kruhft.boldlygoingnowhere.org
Bill Marcum

2006-10-24, 1:17 pm

On 24 Oct 2006 01:24:23 -0700, donghuang.de@googlemail.com
<donghuang.de@googlemail.com> wrote:
> hi
>
> i got it.
> in stead of using `find . -name *.RPT -print`
> i used 'find . -name *.RPT -print'
> `` is not the "same" as ''
>
> can someone give me a hint. what different are there?
> thanks
>

man $SHELL



--
BOFH excuse #51:
Cosmic ray particles crashed through the hard disk platter
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com