What does the line “#!/bin/sh” mean in a UNIX shell script?

后端 未结 5 1806
暗喜
暗喜 2020-11-28 18:59

I was going through some shell script tutorials and found the following sample program:

#!/bin/sh
clear
echo \"HELLO WORLD\"

Can anyone ple

5条回答
  •  我在风中等你
    2020-11-28 19:36

    The first line tells the shell that if you execute the script directly (./run.sh; as opposed to /bin/sh run.sh), it should use that program (/bin/sh in this case) to interpret it.

    You can also use it to pass arguments, commonly -e (exit on error), or use other programs (/bin/awk, /usr/bin/perl, etc).

提交回复
热议问题