Gentoo Archives: gentoo-amd64

From: Maciej Kazulak <kazulakm@×××××.com>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] How to use &&
Date: Sun, 04 Jan 2009 14:31:18
Message-Id: 492f5c190901040631l6b04d06jbd660242b1a915e3@mail.gmail.com
In Reply to: Re: [gentoo-amd64] How to use && by Paul Stear
1 2009/1/4 Paul Stear <gentoo@××××××××××××.com>
2
3 > On Sunday 04 January 2009 12:33:27 Martin Herrman wrote:
4 > > On Sun, Jan 4, 2009 at 1:30 PM, Paul Stear <gentoo@××××××××××××.com>
5 > wrote:
6 > > > Hello all,
7 > > > I have the following command which works well..
8 > > > mp3gain --auto /home/"Fred Music"/mp3/B*/*.mp3
9 > > >
10 > > > I want to expand this so overnight I can get more directories
11 > completed.
12 > > > I tried the following but it only did the directories starting "B", the
13 > > > sequence after the && just wasn't actioned. I have looked at bash docs
14 > > > but can't find anything relevent (probably staring me in the face).
15 > > > mp3gain --auto /home/"Fred Music"/mp3/B*/*.mp3 && mp3gain --auto
16 > > > /home/"Fred Music"/mp3/C*/*.mp3 && mp3gain --auto /home/"Fred
17 > > > Music"/mp3/D*/*.mp3
18 > > >
19 > > > Any ideas?
20 > > > Paul
21 > >
22 > > Hi Paul,
23 > >
24 > > I have created some shell scripts that execute some operations on my
25 > > ogg/mp3 file collection. I use 'find' to create a list of all my files
26 > > and next process them. Ogg2mp3 also uses all of your cores. You might
27 > > use these scripts and adapt them to your needs:
28 > >
29 > > http://www.herrman.nl/index.php?item=ogg2mp3tagfiles
30 > >
31 > > HTH,
32 > >
33 > > Martin
34 >
35 > Thanks for your reply Martin. I have looked at your scripts and I might be
36 > able to use then in the future. My main problem is that my collection is
37 > so
38 > large, e.g 3104 files just in the directory beginning with "D" and that
39 > take
40 > about 4+ hours to run. So I could do with operating on 3 directories
41 > overnight.
42 > I must be able to add commands to be operated on in sequence.
43 >
44 > Any ideas?
45 >
46 > Paul
47 >
48 > --
49 > This message has been sent using kmail with gentoo linux
50 >
51
52
53 The reason only the first command was executed can be that it returned a
54 non-zero exit status. If you want to make sure every command gets a chance
55 to execute, regardless of what the exit status of the previous one is,
56 substitute '&&' with ';'. Check this out:
57 box% false && echo "will not be echoed"
58 box% false; echo "hello"
59 hello
60 box%
61
62 That's how bash evaluates logic expressions. There's even a fancy word for
63 it i think. Point is it will execute commands only to the point where it can
64 determine the logic result. So above if the first element is false there's
65 no need to execute echo as the logic result is already known to be false.

Replies

Subject Author
Re: [gentoo-amd64] How to use && Martin Herrman <martin@×××××××.nl>
Re: [gentoo-amd64] How to use && Richard Freeman <rich0@g.o>