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

Re: bash: for to, reading escaped spaces in filenames



On Sun, July 13 at 11:05 AM EDT
David selby <debian@pusspaws.net> wrote:

>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 ?

Does
$export _tox=key	#key is whatever it is you are searching for
$for file in *${_tox}*; do echo "$file"; done
work the way you want?

Shawn Lamson
shawn.lamson@verizon.net



Reply to: