0

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

Anastasios Andronidis
  • 6,310
  • 4
  • 30
  • 53
  • 1
    learn to use the `set -vx` feature of the cmd line to see how cmds are being executed. you use `set +vx` to turn it off. Good luck. – shellter May 20 '14 at 16:26

2 Answers2

6

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
devnull
  • 118,548
  • 33
  • 236
  • 227
1

That does not work because it only expands the the path. Try this.

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

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