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.pswp.cn/news/390787.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/390787.shtml
英文地址,請注明出處:http://en.pswp.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;然后…