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

  • A beginner's guide to surviving in the Linux shell

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

  • Basic Linux commands to know

    基本的Linux命令要知道

  • Shell scripting tricks

    Shell脚本技巧

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

shell脚本

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/390787.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

大数据与Hadoop

大数据的定义 大数据是指无法在一定时间内用常规软件工具对其内容进行抓取、管理和处理的数据集合。 大数据的概念–4VXV 1,数据量大(Volume)2,类型繁多(Variety )3,速度快时效高(Velocity)4,价值密度低…

Arm汇编指令学习

ARM指令格式 ARM指令格式解析 opcode: 指令助记符,例如,MOV ,ADD,SUB等等 cond:指令条件码表.下面附一张图 {S}:是否影响CPSR的值. {.W .N}:指令宽度说明符,无论是ARM代码还是Thumb(armv6t2或更高版本)代码都可以在其中使用.W宽度说明符&…

facebook.com_如何降低电子商务的Facebook CPM

facebook.comWith the 2020 election looming, Facebook advertisers and e-commerce stores are going to continually see their ad costs go up as the date gets closer (if they haven’t already).随着2020年选举的临近,随着日期越来越近,Facebook…

Python中的If,Elif和Else语句

如果Elif Else声明 (If Elif Else Statements) The if/elif/else structure is a common way to control the flow of a program, allowing you to execute specific blocks of code depending on the value of some data.if / elif / else结构是控制程序流程的常用方法&#x…

Hadoop安装及配置

Hadoop的三种运行模式 单机模式(Standalone,独立或本地模式):安装简单,运行时只启动单个进程,仅调试用途;伪分布模式(Pseudo-Distributed):在单节点上同时启动namenode、datanode、secondarynamenode、resourcemanage…

漏洞发布平台-安百科技

一个不错的漏洞发布平台:https://vul.anbai.com/ 转载于:https://blog.51cto.com/antivirusjo/2093758

Android 微信分享图片

private String APP_ID "00000000000000000"; //微信 APPID private IWXAPI iwxapi; private void regToWx() {iwxapi WXAPIFactory.createWXAPI(context, APP_ID, true);//这里context记得初始化iwxapi.registerApp(APP_ID); } IMServer.getDiskBitmap(IMServer.u…

蒙蒂霍尔问题_常见的逻辑难题–骑士和刀,蒙蒂·霍尔和就餐哲学家的问题解释...

蒙蒂霍尔问题While not strictly related to programming, logic puzzles are a good warm up to your next coding session. You may encounter a logic puzzle in your next technical interview as a way to judge your problem solving skills, so its worth being prepare…

西格尔零点猜想_我从埃里克·西格尔学到的东西

西格尔零点猜想I finished reading Eric Siegel’s Predictive Analytics. And I have to say it was an awesome read. How do I define an awesome or great book? A book that changes your attitude permanently. You must not be the same person that you were before y…

C/C++实现删除字符串的首尾空格

StdStringTrimTest.cpp #include <iostream> int main() {std::string str(" 字符串 String ");std::cout << str << std::endl;std::cout << str.size() << std::endl;str.erase(str.find_first_of( ), str.find_first_not_of…

assign复制对象_JavaScript标准对象:assign,values,hasOwnProperty和getOwnPropertyNames方法介绍...

assign复制对象In JavaScript, the Object data type is used to store key value pairs, and like the Array data type, contain many useful methods. These are some useful methods youll use while working with objects.在JavaScript中&#xff0c; Object数据类型用于存…

HDFS 技术

HDFS定义 Hadoop Distributed File System&#xff0c;是一个使用 Java 实现的、分布式的、可横向扩展的文件系 统&#xff0c;是 HADOOP 的核心组件 HDFS特点 处理超大文件流式地访问数据运行于廉价的商用机器集群上&#xff1b; HDFS 不适合以下场合&#xff1a;低延迟数据…

深度学习算法和机器学习算法_啊哈! 4种流行的机器学习算法的片刻

深度学习算法和机器学习算法Most people are either in two camps:大多数人都在两个营地中&#xff1a; I don’t understand these machine learning algorithms. 我不了解这些机器学习算法。 I understand how the algorithms work, but not why they work. 我理解的算法是如…

Python第一次周考(0402)

2019独角兽企业重金招聘Python工程师标准>>> 一、单选 1、Python3中下列语句错误的有哪些&#xff1f; A s input() B s raw_input() C print(hello world.) D print(hello world.) 2、下面哪个是 Pycharm 在 Windows 下 默认 用于“批量注释”的快捷键 A Ctrl d…

express 路由中间件_Express通过示例进行解释-安装,路由,中间件等

express 路由中间件表达 (Express) When it comes to build web applications using Node.js, creating a server can take a lot of time. Over the years Node.js has matured enough due to the support from community. Using Node.js as a backend for web applications a…

ASP.NET 页面之间传值的几种方式

对于任何一个初学者来说&#xff0c;页面之间传值可谓是必经之路&#xff0c;却又是他们的难点。其实&#xff0c;对大部分高手来说&#xff0c;未必不是难点。 回想2016年面试的将近300人中&#xff0c;有实习生&#xff0c;有应届毕业生&#xff0c;有1-3年经验的&#xff0c…

Mapreduce原理和YARN

MapReduce定义 MapReduce是一种分布式计算框架&#xff0c;由Google公司2004年首次提出&#xff0c;并贡献给Apache基金会。 MR版本 MapReduce 1.0&#xff0c;Hadoop早期版本(只支持MR模型)MapReduce 2.0&#xff0c;Hadoop 2.X版本&#xff08;引入了YARN资源调度框架后&a…

数据可视化图表类型_数据可视化中12种最常见的图表类型

数据可视化图表类型In the current era of large amounts of information in the form of numbers available everywhere, it is a difficult task to understand and get insights from these dense piles of data.在当今时代&#xff0c;到处都是数字形式的大量信息&#xff…

三大纪律七项注意(Access数据库)

三大纪律&#xff08;规则或范式&#xff09; 要有主键其他字段依赖主键其他字段之间不能依赖七项注意 一表一主键(订单表&#xff1a;订单号&#xff1b;订单明细表&#xff1a;订单号产品编号)经常查&#xff0c;建索引&#xff0c;小数据&#xff08;日期&#xff0c;数字类…

CentOS下安装JDK的三种方法

来源&#xff1a;Linux社区 作者&#xff1a;spiders http://www.linuxidc.com/Linux/2016-09/134941.htm 由于各Linux开发厂商的不同,因此不同开发厂商的Linux版本操作细节也不一样,今天就来说一下CentOS下JDK的安装: 方法一&#xff1a;手动解压JDK的压缩包&#xff0c;然后…