0

Neither of these work. Can you tell me why sudo does not work with a function, and is there a way to make it work with a function like this?

yy() { yum upgrade -y; yum upgrade -y; }
sudo yy

or:

sudo $(yum upgrade -y; yum upgrade -y)
Rachid K.
  • 4,490
  • 3
  • 11
  • 30
YorSubs
  • 3,194
  • 7
  • 37
  • 60

1 Answers1

1

You are creating a subshell. What you are doing is executing the output of the command as sudo. Try

sudo bash -c 'yum upgrade -y; yum upgrade -y'
Scala
  • 116
  • 2
  • 7