running consecutive commands in bash Usually to run multiple commands consecutively one would do:

sudo apt update &amp;&amp; sudo apt upgrade # 35 characters


I can't help but feel there's a neat trick to running these with less keystrokes, and you golfers here love challenges :)

I've found a ton of answers around various SE Sites related to running arguments to different commands or commands in parallel, but nothing like what I'm after. 

I've come to achieve what I want a couple of ways, but it's way longer and more difficult to type:

 x=('update' 'upgrade') &amp;&amp; for i in ${x[*]}; do sudo apt $i; done 


I quickly shortened this to:

for x in update upgrade; do sudo apt $x; done


then

for x in update upgrade;do sudo apt $x;done # 43 characters


Using bash, what is a golfed way of achieving the above? shortest line wins

(this is my first post to the group, please be kind if I've used the wrong tags) ;) 

edit: as pointed out my own loops don't exactly do what is in the question due to the &amp;&amp; being conditional on the first command not having an error (I do know this). There's also the fact that my loops (and the original command line without the -y switch) still requires user input to complete. An oversight. Time for some more explicit instructions.

My original thought was to have something like: 

echo update upgrade | sudo apt 


with the objective of just running one after the other. 

In the interests of trying to open this up to other languages, let's expand it thusly:

Objectives:


run both commands
require no more than one additional keystroke by the user
can outsource this to other other languages/scripts*
can be scripted if:


gracefully fails (error messages are ok, but it shouldn't try and execute anything else in error)
it's something commonly or "unobtrusively installable" in linux/ubuntu (I feel I may regret this line)
the script takes at least three arguments

command to run


argument 1


argument 2


argument n

or specified on the command line, (see next example)
in this second case, see the note below

./twice "sudo apt" update upgrade



*I have it in mind that someone could construct a cute little binary/script from a printf, but the essence is, if it can be run from an executable script, all characters of the script EXCEPT the first line (the shebang) count. 

If I've totally messed this up, feel free to close. Cheers
40 bytes

for a in ${@:2};do eval "${1} ${a}";done


Usage: ./[filename] "[primary command]" [arguments]

Ex. ./twice "sudo apt" update upgrade (Assumes 'twice' as file name)

Was this what you wanted?

Note: Please golf me further if it is possible, and correct me if I'm wrong. This was my first bash entry.