Re: bash scripts misrepresenting white space

2003-12-26 Thread Dan Lenski
On Thu, 2003-12-25 at 21:32, Johann Koenig wrote:
 I tried reading the man page and the BASH Programming HOWTO, but I
 couldn't really get what I needed out of either. Oh well, with you're
 example to guide me, I got it right. If anybodies willing, please look
 over the attached script and give any comments that come to mind.
 
 About the script: It runs in the current directory and converts all
 flacs to mp3s. I'm figuring I could wrap it in another script to
 transverse my directory tree, running the conversion script in each one.
 I tried to make it as modular as possible, but I may have gone a little
 overboard.

You might be better off doing this in a scripting language like Perl.  Your script 
would be a lot simpler and you wouldn't have to worry about such annoyances as 
quoting.  There are a zillion modules to easily parse filenames and such...
Dan

--- E.g.: ---

#!/usr/bin/perl
open(FLACS, find . -name '*.flac' |);
while ( FLACS ) { push @FLACS, $_; }
close FLACS;

foreach (@FLACS) {
decode($_);
}

sub decode
{
my $file = shift;
system('flac', '-dc', $file);
}


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash scripts misrepresenting white space

2003-12-26 Thread Colin Watson
On Thu, Dec 25, 2003 at 09:32:05PM -0500, Johann Koenig wrote:
 I tried reading the man page and the BASH Programming HOWTO, but I
 couldn't really get what I needed out of either.

A friend of mine wrote an article on common mistakes in shell
programming, which may help you:

  http://www.greenend.org.uk/rjk/2001/04/shell.html

 Oh well, with you're example to guide me, I got it right. If anybodies
 willing, please look over the attached script and give any comments
 that come to mind.

I haven't had a chance to look in detail, but the tool you want to strip
extensions is basename. Alternatively, look at the ${parameter%word}
syntax under Parameter Expansion in bash(1).

Cheers,

-- 
Colin Watson  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash scripts misrepresenting white space

2003-12-25 Thread Simon Law
On Thu, Dec 25, 2003 at 07:44:16PM -0500, Johann Koenig wrote:
 I try, for example:
 for i in `ls`
 do
 echo $i
 done

You want:

for i in *
do
echo $i
done

which will do what you probably want.  I'd suggest consulting the Bash
info manual which should tell you what you need to know about quoting.

Simon


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Re: bash scripts misrepresenting white space

2003-12-25 Thread Johann Koenig
On Thursday December 25 at 08:45pm
Simon Law [EMAIL PROTECTED] wrote:

 On Thu, Dec 25, 2003 at 07:44:16PM -0500, Johann Koenig wrote:
  I try, for example:
  for i in `ls`
  do
  echo $i
  done
 
 You want:
 
 for i in *
 do
 echo $i
 done
 
 which will do what you probably want.  I'd suggest consulting the Bash
 info manual which should tell you what you need to know about quoting.

I tried reading the man page and the BASH Programming HOWTO, but I
couldn't really get what I needed out of either. Oh well, with you're
example to guide me, I got it right. If anybodies willing, please look
over the attached script and give any comments that come to mind.

About the script: It runs in the current directory and converts all
flacs to mp3s. I'm figuring I could wrap it in another script to
transverse my directory tree, running the conversion script in each one.
I tried to make it as modular as possible, but I may have gone a little
overboard.
-- 
-johann koenig
Now Playing: Social Distortion - Through These Eyes : White Light White
Heat White T
Today is Prickle-Prickle, the 67th day of The Aftermath in the YOLD 3169
My public pgp key: http://mental-graffiti.com/pgp/johannkoenig.pgp


create.mp3s
Description: Binary data


pgp0.pgp
Description: PGP signature