Re: commands

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Kevin Fries
Date:  
To: Main PLUG discussion list
Subject: Re: commands
Michael,

As Matt said, braces expand into the same command, they are not used for
multiple commands. FOR is used for multiple commands. While this is much
more work in my opinion, this would also work... provided that there is no
error.

$ for cmd in update upgrade; do sudo apt-get ${cmd}; done

This runs the two command in serial regardless of the results of either
command. My original answer did not run the second command if the first
command failed.

Kevin
On Dec 22, 2014 11:55 PM, "Michael Havens" <> wrote:

> thank you Matt and Kevin. I was looking for a way to combine the two
> commands with the curly brackets.
>
> :-)~MIKE~(-:
>
> On Mon, Dec 22, 2014 at 11:36 PM, Matt Birkholz <>
> wrote:
>
>> > From: Michael Havens <>
>> > Date: Mon, 22 Dec 2014 15:46:23 -0700
>> >
>> > I was thinking, I could type in 'sudo apt-get update;sudo apt-get
>> > upgrade' but what would be a more efficient way?
>> >
>> > [...]
>> >
>> > sudo apt-get {update, upgrade}
>> > E: Invalid operation {update,
>> >
>> > This is interesting: when I typed in 'sudo {apt-get {update; upgrade}}'
>> it
>> > didn't give me an error for '{update'
>> >
>> > So does anyone know what I'm talking about and how to do it?
>>
>> Brace expansion is performed on a command. A semicolon separates
>> commands. Your command line
>>
>>         sudo {apt-get {update; upgrade}}

>>
>> is interpreted as two commands:
>>
>>         sudo {apt-get {update
>>         upgrade}}

>>
>> So sudo complains about a strange command name "{apt-get", the
>> argument "{update" passes without comment, and the shell complains
>> about the command name "upgrade}}".
>>
>> You cannot stick an unescaped semicolon inside braces.
>>
>> Most efficient? Stick this in ~/.bashrc
>>
>>         alias do-it='sudo sh -c "apt-get update; apt-get upgrade"'

>>
>> so you can say just
>>
>>         do-it

>>
>> ?
>> ---------------------------------------------------
>> PLUG-discuss mailing list -
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss