This is a discussion on bash scripting question within the Linux General forums, part of the Linux Forums category; > for n in *.mps > do > lame --decode "$n" > done > Thank you for all ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
> for n in *.mps
> do > lame --decode "$n" > done > Thank you for all the responses, it was so simple. But I have a book called "Linux System Administration" by Vicky Stanfield and Roderick W. Smith that has the following example to play various wav files: for d in `ls *.wav`; do play $d; done And then a big "Warning": "This loop syntax uses spaces to delineate files, so if a filename includes a space, your script won't be able to parse the files correctly. [...] This is one of the reasons experienced Linux users don't create files with spaces in their names." Instead of giving this simple solution to the problem it suggests to use file names without spaces in it. I dont understand why. |
|
|||
|
On Sun, 10 Aug 2003 at 17:57 GMT, Francisco wrote:
>> for n in *.mps >> do >> lame --decode "$n" >> done >> > > Thank you for all the responses, it was so simple. > But I have a book called "Linux System Administration" by Vicky Stanfield > and Roderick W. Smith that has the following example to play various wav > files: > for d in `ls *.wav`; do play $d; done > > And then a big "Warning": > "This loop syntax uses spaces to delineate files, so if a filename includes > a space, your script won't be able to parse the files correctly. [...] This > is one of the reasons experienced Linux users don't create files with > spaces in their names." Get a new book; that is NEVER the correct way. > Instead of giving this simple solution to the problem it suggests to use > file names without spaces in it. I dont understand why. Many scripts will fail when they have to deal with file names containing spaces; it's not hard to accommodate them, but their use is fairly recent (not to mention an abomination) and many scripts predate the influx of Windows-type file names. -- Chris F.A. Johnson http://cfaj.freeshell.org ================================================== ================= My code (if any) in this post is copyright 2003, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License |
|
|||
|
Francisco <fran575@mailandnews.com> wrote:
>> for n in *.mps >> do >> lame --decode "$n" >> done > Thank you for all the responses, it was so simple. > But I have a book called "Linux System Administration" by Vicky Stanfield > and Roderick W. Smith that has the following example to play various wav > files: > for d in `ls *.wav`; do play $d; done > And then a big "Warning": > "This loop syntax uses spaces to delineate files, so if a filename includes > a space, your script won't be able to parse the files correctly. [...] This > is one of the reasons experienced Linux users don't create files with > spaces in their names." > Instead of giving this simple solution to the problem it suggests to use > file names without spaces in it. I dont understand why. Because creating file names with spaces in is creating problems for yourself. No administrator would do it. And you have a book about admonistration. That's what they SAY! Peter |
|
|||
|
> Francisco <fran575@mailandnews.com> wrote:
>> But I have a book called "Linux System Administration" by Vicky Stanfield >> and Roderick W. Smith that has the following example to play various wav >> files: >> for d in `ls *.wav`; do play $d; done Wouldn't it be easier just "for d in *.wav"? What is the point of `ls *.wav` there? Vilmos |
|
|||
|
On Sun, 10 Aug 2003 at 19:43 GMT, Alan Connor wrote:
>> >>> for n in *.mps >>> do >>> lame --decode "$n" >>> done > Perhaps when the book was written her shell didn't have the functionality > to use Chris's solution (?). That is a generic solution that will work in any Bourne-type shell (assuming the existence of "lame"). -- Chris F.A. Johnson http://cfaj.freeshell.org ================================================== ================= My code (if any) in this post is copyright 2003, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License |
|
|||
|
In article <bh6124$uv1qc$1@ID-99245.news.uni-berlin.de>, Francisco wrote:
> Thank you for all the responses, it was so simple. But I have a > book called "Linux System Administration" by Vicky Stanfield > and Roderick W. Smith that has the following example to play > various wav files: > > for d in `ls *.wav`; do play $d; done > > And then a big "Warning": > "This loop syntax uses spaces to delineate files, so if a filename includes > a space, your script won't be able to parse the files correctly. [...] This > is one of the reasons experienced Linux users don't create files with > spaces in their names." > > Instead of giving this simple solution to the problem it suggests to use > file names without spaces in it. I dont understand why. I Don't know either. It certainly suggests the authors aren't paying attention or don't do much bash scripting. -- Grant Edwards grante Yow! WHOA!! Ken and at Barbie are having TOO visi.com MUCH FUN!! It must be the NEGATIVE IONS!! |
|
|||
|
In article <mc36hb.1qt.ln@news.it.uc3m.es>, Peter T. Breuer wrote:
>> Instead of giving this simple solution to the problem it suggests to use >> file names without spaces in it. I dont understand why. > > Because creating file names with spaces in is creating problems for > yourself. No administrator would do it. And no decent bash programmer would write a script that can't handle spaces in file names. > And you have a book about admonistration. That's what they SAY! -- Grant Edwards grante Yow! Yow! I want my nose at in lights! visi.com |
|
|||
|
Grant Edwards <grante@visi.com> wrote:
> In article <mc36hb.1qt.ln@news.it.uc3m.es>, Peter T. Breuer wrote: >>> Instead of giving this simple solution to the problem it suggests to use >>> file names without spaces in it. I dont understand why. >> >> Because creating file names with spaces in is creating problems for >> yourself. No administrator would do it. > And no decent bash programmer would write a script that can't > handle spaces in file names. Well, probably the fifth iteration at writing his script handles most of those cases. Peter |