我如何用linux基本脚本?

时间:2016-04-13 16:23:38

标签: linux bash shell unix

这个命令做什么?

!/bin/bash

我的第一个脚本

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

2 个答案:

答案 0 :(得分:0)

#!/bin/bash告诉SO该文件是一个脚本,而bash是必须执行它的shell。所以你可以找到:#!/opt/bin/perl用于perl脚本,#!/bin/csh用于c-shell,#!/bin/zsh ...

答案 1 :(得分:0)

#!/bin/bash被称为shebang(您错过了领先#)。 它告诉哪个程序将执行你的脚本。

clear用于清除屏幕。

echo输出标准输出的参数(默认情况下是您的终端)。但是你不能用括号括起你的字符串,因为它用于在子shell中分组命令。如果你想打印(...),你也会使用双引号:

echo "(I don't know what will come after echo , can you help me with that too?)"
在您使用./hello.shell授予执行权限后,

chmod +x hello.shell将执行您的脚本。

请注意,shell脚本的常用扩展名为.sh而不是.shell

有关更多信息,请尝试这些链接:

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

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