Re: Bash question
Stephan Sauerburger <firstname.lastname@example.org> writes:
> In a for loop which runs through all files, as in:
> for file in `ls`
ITYM 'for file in *'...
> ...will do just a fine job, so long as none of the file names have any
> spaces in them.
because it gets around this. In general, you want to be careful if
you're dealing with files with spaces in their names, since the shell
will be enthusiastic about breaking words.
for file in *.ogg; do
(Since the double-quotes allow variable expansion, but force the
result to be a single "world" for shell purposes.)
> Then the preceding instructions first try to play "Aerosmith", then
> "-", then "Walk", then "This", then "Way.mp3", then "(They"... you get the
> idea. All of which fail, and this could lead to dangerous results if you're
> doing something other than mpg123 to it, like "rm", and there were also a
> file simply called "Aerosmith".
ISTR earlier versions of Mac OS X, which is built on top of some BSD,
having issues like this as well.
David Maze email@example.com http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
- Bash question
- From: Stephan Sauerburger <firstname.lastname@example.org>