When I install a LAMP server environment on Debians I use this code:

apt-get upgrade lamp-server^ php-cli php-curl php-mbstring php-mcrypt php-gd python-certbot-apache -y

If I add more php-X packages it becomes uglylically long.

Is there a way to shorten it a bit like as follows?

apt-get upgrade lamp-server^ php-cli|curl|mbstring|mcrypt|gd python-certbot-apache -y
  • 3
    I may sound like a broken record, but apt-get upgrade upgrades all installed packages (in addition to doing what you’re asking it to do here). apt-get install is the usual command to install packages. (Of course, if you do want to upgrade at the same time, why not, I suppose.) – Stephen Kitt Nov 8 '18 at 22:05
  • @StephenKitt as the actual sequence is longer and contains other utilities likely to already come with my distro, indeed, I desire to upgrade all utilities in the sequence. Thank you for this comment. – JohnDoea Nov 9 '18 at 14:17

Yes, you can use bash brace expansion to generate the arguments with the same prefix.

The correct syntax would be:

apt-get upgrade lamp-server^ php-{cli,curl,mbstring,mcrypt,gd} python-certbot-apache -y

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.