On Monday 06 November 2006 14:26, Lucky Leavell wrote:
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
The 'for' command parses every token in each line returned by `ls -l *.mp3`. Instead try a_command_that_produces_output_lines_with_spaces | while read one_line do echo $one_line done Note that the trivial example script above should produce identical output to simply entering a_command_that_produces_output_lines_with_spaces Jim
Lucky Leavell