[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash question

On Tuesday 01 July 2003 9:46 am, Stephan Sauerburger wrote:
> How do I have it make sure it iterates file-by-file? The following example,
> to play all mp3s in the current directory:
> for file in `ls`
> do
>   mpg123 $file
> done
> ...will do just a fine job, so long as none of the file names have any
> spaces in them. If my directory contained:
> Aerosmith - Walk This Way.mp3
> (They Might Be Giants) - Istanbul.mp3
> Pink Floyd - The Wall.mp3

I'm far from beeng an expert but I thing that you need to do is change the 
Internal Field Separator IFS to a new line (the default is space).

It goes:

#Setting the Internal Field Separator to '\n'

for a in `ls`; do mpg123 $a; done

Good Luck 



Reply to: