How can I make several commands to be executed after a && or a ||?

Johnny Rosenberg gurus.knugum at gmail.com
Sat Feb 18 12:17:46 UTC 2012


2012/2/17 PleegWat <pleegwat at telfort.nl>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 02/17/2012 11:08 PM, Johnny Rosenberg wrote:
>> Something like the following, described in some kind of
>> self-invented pseudo code:
>>
>> If ThisCommand exits successfully { printf("Something");
>> SomeVariable=3; } DoSomethingElse
>>
>>
>> How could I do something similar with bash?
>>
>> You know, something like this:
>>
>> ThisCommand && ( echo $Something SomeVariable=3) DoSomethingElse
>>
>>
>> What's the syntax for this?
>
> What you've written should work; if it doesn't play with the whitespace.
>
> However, shell script also has an if command. This is even usable on
> the interactive shell.
>
> if ThisCommand
> then
>        echo $Something
>        SomeVariable=3
> fi
> DoSomethingElse

Thanks for replying. The reason I asked was not that I tried make
something work and failed, I was rather that I was trying to do it in
a specific way, so my question was only about && and || respectively,
and nothing else. I guess I could have mentioned that. My bad, sorry.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ




More information about the ubuntu-users mailing list