How to work with spaces in filenames

How to work with spaces in filenames

Post by Jens-Uwe Spierin » Sun, 19 Nov 2000 04:00:00



Hi all,
i am looking for some files ending with .Prefs and want to add them to a
scrolled List Widget,
but i have difficulties to handle those files which have spaces in their
filenames
so for the moment i just use sed to convert those spaces forward and backward
although its working its looks a bit strange to me.
Is there a better solution??


'Start.Prefs'`

                do
                File=${i##/*/}

                XmListAddItemUnselected $scrolledList1 0 "$File"
        done

Thanks for any reply
-jens-

 
 
 

How to work with spaces in filenames

Post by bmar.. » Sun, 19 Nov 2000 04:00:00



   >Hi all,
   >i am looking for some files ending with .Prefs and want to add them
   >to a scrolled List Widget,
   >but i have difficulties to handle those files which have spaces in
   >their filenames
   >so for the moment i just use sed to convert those spaces forward
   >and backward although its working its looks a bit strange to me.
   >Is there a better solution??

   >grep -v 'Start.Prefs'`
   >do
   >File=${i##/*/}

   >XmListAddItemUnselected $scrolledList1 0 "$File"
   >done
find "$PPath" -name "*.Prefs" ! -name "Start.Prefs" -print |
  while read File
  do
  XmListAddItemUnselected $scrolledList1 0 "$File"
  done

Net-Tamer V 1.08X - Test Drive

 
 
 

1. bash and working on filenames with spaces

Hi,

I was wondering how you usually do a for loop in a bash shell script that
should work on filenames it reads from a directory when those file names
contain spaces:

$ for name in $(ls --format=single-column)

will print:
a
b
c
for a file called "a b c"
First I tried to substitute the internal field separator to <newline>:
IFS="\n"
which does not work, multiple files "a b c", "d e f" don't get detected.

Then I tried replacing the newline with "#" by changing the $(ls ...
command:
$(ls --format=single-column | sed 's/$/#/')
And adjusting IFS="#", but unfortunately sed always appends a newline
character... :(

So, how do you do stuff like that?
a) don't use spc in filenames ;)
b) ...?

Thanks
Uwe
--

2. sed question

3. 'No space left on device' with long filenames, but short ones work

4. ET4000 & WB2C490 Ramdac problem. Workaround?

5. how do 'plug-ins' work?

6. Netatalk not working with RH 6.2

7. IP Accounting doesn't work for PPP dial-ins :-(( ??

8. Calcom modem

9. Does uemacs really work ins SysV.2?

10. Using tar with filenames that have blank spaces

11. !! Filenames with spaces problem !!

12. filename spaces cause multiline input from "for file in ls -1t"

13. Embedded spaces in filenames throw Netscape