[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash: for to, reading escaped spaces in filenames



Hello,

I need to scan a directory for the file names contained in it.

for _scantox in $(ls $_tox); do
.....
done

works just file with _scantox holding the file name, However some of the file names are in the form of
342345\ remind\ for\ apt-get\ update

ie they have escaped spaces in the name. I have tried just about everything I can think of to read these in a for do loop.
If I ..
for _scantox in test test\ number\ 27; do ....
it works OK, so I know it accepts escaped spaces

I have tried "$(ls -b1 $_tox)", which gives me ...#

web@debian:/usr/local/myfiles/dave/debian/sh files$ ./remind2
test
this\
is\
a\
test
web@debian:/usr/local/myfiles/dave/debian/sh files$

near but I need the filename in one piece ! ie test & this\ is\ a\ test

Without resorting to complex string manipulation & cutting, is there a neat way to do this ?

Dave



Reply to: