I have made a script for recursive listing of files in directories...

#!/bin/sh
# Creates a standard output stream of all files matching the pattern in
parameter $1, including the path.

for FILE in $(ls $1 2>/dev/null); do
  echo \"$(pwd)/$FILE\"
done

for DIR in $(ls) ; do
  if [ -d $DIR ] ; then
    cd $DIR ;
    recursive $1 ;
    cd ..
  fi
done

The output will contain the full path to the files, and I have quotes
(") around to handle space in directory/file names.

But, if I do a

rm $( recursive *.abc)

the script processor will break a directory name at the space, serving
'rm' with multiple files, such as

original;
"/home/niclas/java dev/project/file.abc"

as
"/home/niclas/java
dev/project/file.abc"

Resulting in complete failure.
Can anyone explain why and if there is anything I can do about it, not
including removing the spaces in directory and file names?
Perhaps there is a command that does what I need, and that is well and
dandy, but I would still want an answer for future scripting experience.



Niclas

Reply via email to