失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > shell脚本_Shell脚本

shell脚本_Shell脚本

时间:2024-07-18 12:12:45

相关推荐

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 fileexecutionmode:

给出文件执行方式:

$ chmod +x myscript.sh

Execute it!

执行它!

$ ./myscript.shHello World!

More info about shell-scripting can be found here

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

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

A beginner's guide to surviving in the Linux shell

在Linux Shell中生存的初学者指南

Basic Linux commands to know

基本的Linux命令要知道

Shell scripting tricks

Shell脚本技巧

翻译自: /news/shell-scripting/

shell脚本

如果觉得《shell脚本_Shell脚本》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。