how do I basic script with linux? [closed]

2019-10-02 02:49发布

what does this command do?

!/bin/bash

My first script

clear
echo (I don't know what will come after echo , can you help me with that too?)
./hello.shell

2条回答
2楼-- · 2019-10-02 03:35

#!/bin/bash tells to the SO that this file is a script and that bash is the shell that must execute it. So you can found: #!/opt/bin/perl for perl scripts, #!/bin/csh for c-shell, #!/bin/zsh ...

查看更多
看我几分像从前
3楼-- · 2019-10-02 03:40

#!/bin/bash is called the shebang (you missed the leading #). It tells which program will execute your script.

clear is for clearing screen.

echo outputs following argument to the standard output (your terminal by default). But you must not surround your string with parenthesis as it's used for grouping command in a sub-shell. If you want to print (...), you'll have too use double quotes :

echo "(I don't know what will come after echo , can you help me with that too?)"

./hello.shell will execute your script after you gave it execute permissions with chmod +x hello.shell.

Note that commonly used extension for a shell script is .sh rather than .shell.

For more, try theses links :

http://mywiki.wooledge.org/BashGuide/

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/

查看更多
登录 后发表回答