Search code examples
bashcurly-brackets

execute commands with curly brackets on bash


I would like to know why the following command is not working in Bash and how it's possible to make it run:

/etc/init.d/{httpd,nscd} status

Thanks


Solution

  • Your command doesn't work because it'd execute:

    /etc/init.d/httpd /etc/init.d/nscd status
    

    One way of achieving what you want would be to make use of a loop:

    for util in /etc/init.d/{httpd,nscd} ; do
      ${util} status
    done