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

Johnny Rosenberg gurus.knugum at gmail.com
Sat Feb 18 12:24:51 UTC 2012


2012/2/18 Alexander Skwar <alexanders.mailinglists+nospam at gmail.com>:
> Hi.
>
> 2012/2/17 Johnny Rosenberg <gurus.knugum at gmail.com>
>>
>>
>> You know, something like this:
>>
>> ThisCommand && (
>>        echo $Something
>>        SomeVariable=3)
>> DoSomethingElse
>>
>
> Exactly this works. With "( … )", you spawn a subshell.

Yes, I saw something about that when I googled for the answer, but I
just didn't understand that subshell thing (maybe because my native
language is not English). Seems like it creates a separate process.
Does this mean that what's in the parentheses is executed at the same
time as ”DoSomethingElse” in this case? Could that be a bad thing in
some cases?

Another obvious solution would of course be to create a function that
does everything inside the parentheses, and just call it on a single
line, but that was not what I was asking about.



Kind regards

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




More information about the ubuntu-users mailing list