dirkraft
April 2nd, 2010, 05:49 PM
I've spent days on this now trying all kinds of things to get this for loop to work. My script is a bit more involved than this, but all my problems boil down to this.
dirkraft@ubuntu:~/Desktop/local$ find test/
test/
test/fileone
test/filetwo
dirkraft@ubuntu:~/Desktop/local$ cat printfiles.sh
#!/bin/sh
IFS=$'\n'
for x in `find test/`
do
echo "FILE"
echo $x
done
dirkraft@ubuntu:~/Desktop/local$ ./printfiles.sh
FILE
test/
test/fileo
FILE
e
test/filetwo
dirkraft@ubuntu:~/Desktop/local$
Output should have been very simple:
FILE
test/
FILE
test/fileone
FILE
test/filetwo
How can I loop over the results of a 'find' command?!
Thanks.
dirkraft@ubuntu:~/Desktop/local$ find test/
test/
test/fileone
test/filetwo
dirkraft@ubuntu:~/Desktop/local$ cat printfiles.sh
#!/bin/sh
IFS=$'\n'
for x in `find test/`
do
echo "FILE"
echo $x
done
dirkraft@ubuntu:~/Desktop/local$ ./printfiles.sh
FILE
test/
test/fileo
FILE
e
test/filetwo
dirkraft@ubuntu:~/Desktop/local$
Output should have been very simple:
FILE
test/
FILE
test/fileone
FILE
test/filetwo
How can I loop over the results of a 'find' command?!
Thanks.