shell脚本_Shell脚本

shell脚本

In the command line, a shell script is an executable file that contains a set of instructions that the shell will execute. Its main purpose is to reduce a set of instructions (or commands) in just one file. Also it can handle some logic because it’s a programming language.

在命令行中,shell脚本是一个可执行文件,其中包含该Shell将执行的一组指令。 它的主要目的是减少一个文件中的一组指令(或命令)。 由于它是一种编程语言,因此它还可以处理一些逻辑。

如何建立 (How to create it)

Create the file:

创建文件:

$ touch myscript.sh

Add a shebang at the start of the file. The Shebang line is responsible for letting the command interpreter know which interpreter the shell script will be run with:

在文件的开头添加一个Shebang 。 Shebang行负责让命令解释器知道将运行shell脚本的解释器:

$ echo "#!/bin/bash" > myscript.sh
# or
$ your-desired-editor myscript.sh
# write at the first line #!/bin/bash

Add some commands:

添加一些命令:

$ echo "echo Hello World!" >> myscript.sh

Give the file execution mode:

给出文件执行方式:

$ chmod +x myscript.sh

Execute it!

执行它!

$ ./myscript.sh
Hello World!

More info about shell-scripting can be found here

有关shell脚本的更多信息,请参见此处。

有关Shell脚本和Linux的更多信息: (More info on shell scripting and Linux:)

翻译自: https://www.freecodecamp.org/news/shell-scripting/

shell脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值