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 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 at 14:17
up vote 3 down vote accepted

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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