Using filenames with spaces in Korn Shell
2007-12-24 21:20:00
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 at caprion.com
________________________________
Que serait la vie sans le parachutisme?
Vive l'iti! 8^)
Comments
Got something to say?
You must be logged in to post a comment.

