News for hackers. Stuff that matters.
Re:Top Unix Command Line Utilities by decklin on Sunday December 30, 2012 @12:54PM (#4986483)
The for loop works fine. Performing word splitting/wildcard expansion/etc on a variable will, well, split it into words/expand wildcards/etc, whether it was introduced by a for loop or not.
Re:Top Unix Command Line Utilities by stiff on Sunday December 30, 2012 @01:16PM (#4986551)
I am not sure I understand what you mean. Word-splitting is performed by the "for x in y" construct, using the IFS variable, so by default if you have a file called "foo bar.mp4" the command line from the article:

  for i in *.mp4; do ffmpeg -i "$i" "${i%.mp4}.mp3"; done
will result in executing:

  ffmpeg -i foo foo.mp3
  ffmpeg -i bar.mp4 bar.mp3
Which is obviously not what was meant. So it's a good habit to learn to loop over files in a directory in a different way.
Re:Top Unix Command Line Utilities by decklin on Sunday December 30, 2012 @08:31PM (#4987894)
Maybe you are confusing this with what happens when you do

    for i in `find -name '*.mp4'`; do # ...
or similar. In that case, the output of `find` is indeed split first, and `for` sees "foo", "bar.mp4", and so on.
Re:Top Unix Command Line Utilities by stiff on Monday December 31, 2012 @02:16AM (#4988687)
Ah yes, you are right, thanks!
Re:Top Unix Command Line Utilities by kps on Sunday December 30, 2012 @06:19PM (#4987516)
Perhaps you have a very broken shell.

  $ function echon { echo $# $*; }                    
  $ >'foo bar.mp4'
  $ for i in *.mp4; do echon "$i" "${i%mp4}mp3"; done 
  2 foo bar.mp4 foo bar.mp3