SUMMARY: Using filenames with spaces in Korn Shell

From: Benoit Audet <baudet_at_caprion.com>
Date: Fri Nov 30 2001 - 08:55:25 EST
Well, fast replys for a quick solution!  That's the way I like it!

Special thanks to:

John Julian
Stephen Harris
Ed Rolison
David Glass
Michael Vang
Samier Kesou
Casper Dik
Bertrand Hutin
Ozgur C. Demir

Ok, now it seems to have many, many, many suitable solutions, and maybe 
some are more reliable for more complicated scripts, etc.  But, for this 
case, I choose a simple way to do it.

All of you agreed that I choose a wrong way to get my filenames from the 
file, with the "for" and the "awk" statement.

Here's the way I used:

while read filename
do
         ls -al "$filename"
done < file1

Thanks again!


My original posting was:

>Hi everyone,
>
>I'm trying to do a Korn Shell script that will be able to manipulates 
>filenames with space characters in it, and for each space in a filename, 
>the shell seem to take it for a linefeed...
>
>Here's an example.  Imagine I have a file called "file1", with these three 
>entries in it:
>/export/home/baudet/This_Is_The_First_File
>/export/home/baudet/This_Is_The_Second_File
>/export/home/baudet/This_Is The_Third_File
>(Note the space on the third line, between the "Is" and the "The"...).
>
>If a do this little script:
>#!/bin/ksh
>for filename in `awk '{print $0}' file1`
>do
>                 ls -al "${filename}"
>done
>the "ls -al" command, with or without the " character, is giving me the 
>correct output for the two first lines in the file, but not for the last 
>one, giving me this output:
>/export/home/baudet/This_Is  not found
>The_Third_File  not found
>I'm sure that Korn Shell have a way ton handle these kind of files with 
>space in, but I don't know how.  If some of you could give me a hint on 
>this, I would appreciate the help!
>
>Thanks, will summarise.

________________________________
    Benoit Audet

    Administrateur Unix (Sun Solaris)
    Caprion Pharmaceutiques
    7150, Rue Alexander-Fleming
    Montreal (QC), H4S 2C8
    514.940.3600 ext. 3877

    baudet@caprion.com
________________________________
Que serait la vie sans le parachutisme?
Vive l'iti!  8^) 
Received on Fri Nov 30 13:55:25 2001

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:32:36 EDT