What does /bin/sh -c
mean? What does -c
do?
#!/bin/sh: It is used to execute the file using sh, which is a Bourne shell, or a compatible shell. #!/bin/csh: It is used to execute the file using csh, the C shell, or a compatible shell.
Basically bash is sh, with more features and better syntax. Most commands work the same, but they are different. Bash (bash) is one of many available (yet the most commonly used) Unix shells. Bash stands for "Bourne Again SHell",and is a replacement/improvement of the original Bourne shell (sh).
/bin/sh is an executable representing the system shell and usually implemented as a symbolic link pointing to the executable for whichever shell is the system shell. The system shell is basically the default shell that the script should use.
You don't need to and you shouldn't unless you have no choice. Use '#!/bin/sh' while you can and learn about the difference between a (POSIX) shell and bash.
From the man-page of bash:
-c string
If the
-c
option is present, then commands are read fromstring
. If there are arguments after the string, they are assigned to the positional parameters, starting with$0
.
Example:
$ bash -c ls
will launch bash and execute the command ls
.
/bin/sh
is usually a symlink to a shell.
With -c (command) it returns to the first shell instead of let open a new one.
It is very similar to: sudo su -l -c 'echo "run a command and return"'
Example:
#sudo su -l knoppix -c 'echo "run a command as ${USER} and return"'
run a command as knoppix and return
#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With