bash scripting question

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 ...


Go Back   Usenet Forums > Linux Forums > Linux General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 08-10-2003
Francisco
 
Posts: n/a
Default Re: bash scripting question

> 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.

Reply With Quote
  #12 (permalink)  
Old 08-10-2003
Chris F.A. Johnson
 
Posts: n/a
Default Re: bash scripting question

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
Reply With Quote
  #13 (permalink)  
Old 08-10-2003
Peter T. Breuer
 
Posts: n/a
Default Re: bash scripting question

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
Reply With Quote
  #14 (permalink)  
Old 08-10-2003
Vilmos Soti
 
Posts: n/a
Default Re: bash scripting question

> 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
Reply With Quote
  #15 (permalink)  
Old 08-10-2003
Chris F.A. Johnson
 
Posts: n/a
Default Re: bash scripting question

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
Reply With Quote
  #16 (permalink)  
Old 08-11-2003
Grant Edwards
 
Posts: n/a
Default Re: bash scripting question

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!!
Reply With Quote
  #17 (permalink)  
Old 08-11-2003
Grant Edwards
 
Posts: n/a
Default Re: bash scripting question

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
Reply With Quote
  #18 (permalink)  
Old 08-11-2003
Peter T. Breuer
 
Posts: n/a
Default Re: bash scripting question

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:45 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0