[plug] Simple bash scripting problem

Craig Ringer craig at postnewspapers.com.au
Mon Oct 10 17:48:21 WST 2005


Timothy White wrote:
> Ok. So this should be easy. I don't want to write this script in perl,
> I have most of it in bash already so I would like a nice simple
> answer. (Google's not being my friend, probably cause I'm tired)
> 
> This script basically does a number of operations on a list of files.
> The problem is getting the list to work.
> 
> I call the script similar to this "script *.flac" and what it to
> obviously work on all the flac files... bash expands the *.flac to a
> list of files. Unfortunately all the files have spaces in the names...
> So the 'for list in word' part splits it on the spaces! What is the
> easy solution?
> 
> Thanks
> 
> Tim
> [1] The problem part....
> for file in $*; do

[craig at albert ~]$ cat test.sh
for item in "$@"; do
         echo "Item is: $item"
done
[craig at albert ~]$ sh ./test.sh a b "cde" f
Item is: a
Item is: b
Item is: cde
Item is: f

--
Craig Ringer



More information about the plug mailing list