space char shell script problem

David Banning david+dated+1219918782.39167f at
Sat Aug 23 10:39:42 UTC 2008

I am running into a problem with the space character in filenames.
For instance, If I want to run the script;

for x in `ls`
  echo $x

then filenames that have a space in them ie: "john smith.jpg"
are processed by my script as two names, "john" and "smith.jpg".

What is the best way to deal with this type of space problem in the shell?

I know that file names in quotes solves some problems but I can't tranfer
that to my script.

More information about the freebsd-questions mailing list