On Thu, Jan 07, 2010 at 03:38:23PM +0530, Foss User wrote: > This is my directory structure: > . > | a.sh > | a.txt > | > +---foo bar > | b.txt > | > +---santa > | | c.txt > | | > | \---humpty dumpty > | e.txt > | > \---test > d.txt > > I want to do some operation on each file ending with .txt. However, > this script wouldn't work because in each iteration it gets one word > from the output of find. > > Script: > > for file in `find -name "*.txt"` > do > echo file: $file > done > > Execution: > > $ sh a.sh > file: ./a.txt > file: ./foo > file: bar/b.txt > file: ./santa/c.txt > file: ./santa/humpty > file: dumpty/e.txt > file: ./test/d.txt > > You can see how ./santa/humpty dumpty/e.txt has been broken into two > iterations. Any way to resolve this?
do man bash or man sh or man dash which ever you are using and look up
IFS
oIFS="$IFS"
IFS='
'
for file in `find -name "*.txt"`
do
echo file: $file
done
IFS="$oIFS"
I think should work
>
>
--
"In other words, I don't think people ought to be compelled to make the
decision which they think is best for their family."
- George W. Bush
12/11/2002
on smallpox vaccinations, Washington, D.C.
signature.asc
Description: Digital signature

