Il giorno Mon, 6 Nov 2006 17:26:47 -0500 (EST) Lucky Leavell <susemisc@UniXpress.com> ha scritto:
I am trying to write a simple bash script to handle files with embedded spaces in the filename. For example, a listing of a directory using "ls -1" gives:
ls -l *.mp3 -rw-r--r-- 1 lucky users 20168832 2006-11-03 17:54 01 Allegro.mp3 -rw-r--r-- 1 lucky users 8105984 2006-11-03 17:53 02 Adagio un poco mosso.mp3 -rw-r--r-- 1 lucky users 10661760 2006-11-03 17:53 03 Rondo - Allegro.mp3
The following simplified script
for i in `ls -1 *.mp3` do echo $i done
produces the following output:
01 Allegro.mp3 02 Adagio un poco mosso.mp3 03 Rondo
Allegro.mp3
I have tried various combinations of single and double quotes to no avail including redirecting the "ls -1" listing to a file and escaping the spaces with a backslash, again to no avail.
Surely there must be some trick I can use to handle this anomoly.?
Read Advanced Bash-scripting guide by Mendel Cooper!
Thank you, Lucky Leavell
emilio