shell bash脚本
A scripting language is a programming language supports writing simply to medium level applications in operating systems like Linux, Ubuntu, Debian, CentOS, Windows, MacOS, BSD, Unix. Scripting languages can be used to run complex tasks automatically or manually with very little effort. We can describe actions in a scripting language and run them easily. In this tutorial, we will look at popular scripting languages used by different operating systems and platforms.
脚本语言是一种编程语言,支持在Linux,Ubuntu,Debian,CentOS,Windows,MacOS,BSD,Unix等操作系统中仅向中等级别的应用程序编写代码。 脚本语言可用于自动或手动运行复杂的任务,而无需花费太多精力。 我们可以用脚本语言描述动作并轻松运行它们。 在本教程中,我们将研究不同操作系统和平台使用的流行脚本语言。
重击 (Bash)
Bash
is the king of the scripting languages. bash
provides very convenient programming features. Linux, Unix and BSD platforms fully support bash
. If you want to learn more about bash look following the tutorial.
Bash
是脚本语言之王。 bash
提供了非常方便的编程功能。 Linux,Unix和BSD平台完全支持bash
。 如果您想了解有关bash的更多信息,请查看本教程。
Following bash script will print Hello World
to the standard output which is terminal in most cases.
以下bash脚本会将Hello World
打印到标准输出(在大多数情况下为终端)。
#!/bin/bash
echo "Hello World"
嘘 (Sh)
sh
is the limited version of the Bash
. It provides basic features for the scripting environment. We can use sh
in most of the daily operating like Bash
. The following example will print Hello World
to the terminal.
sh
是Bash
的受限版本。 它提供了脚本环境的基本功能。 我们可以在大多数日常操作中使用sh
,例如Bash
。 下面的示例将Hello World
打印到终端。
#!/bin/sh
echo "Hello World"
Python (Python)
Python is a popular programming and scripting language used in different platforms and applications. Python can be used to develop Desktop Applications, Web Applications, Scripts, Cloud Applications etc. There are a lot of ready to use Python scripts to be used in Linux, BSD, Unix, Windows, MacOS. Python provides a full feature set of programming languages. Python has two main versions numbered as 2 and 3.
Python是一种流行的编程和脚本语言,可用于不同的平台和应用程序。 Python可用于开发桌面应用程序,Web应用程序,脚本,云应用程序等。在Linux,BSD,Unix,Windows,MacOS中有许多现成的Python脚本可供使用。 Python提供了一套完整的编程语言功能。 Python有两个主要版本,分别为2和3。
In this example we will print Hello World
to the standard output.
在此示例中,我们将Hello World
打印到标准输出。
#!/usr/bin/python3
print("Hello World")
微软DOS (MS-DOS)
MS-DOS is actually an operating system used 1980’s and 1990’s actively by Microsoft. But with GUI based operating system it’s used as an auxiliary tool for low-level operations like scripting and issuing commands. MS-DOS provides some programming features and structures. In this example, we will print Hello World
to the MS-DOS command prompt.
MS-DOS实际上是Microsoft在1980年代和1990年代积极使用的操作系统。 但是在基于GUI的操作系统中,它用作脚本和发出命令之类的低级操作的辅助工具。 MS-DOS提供了一些编程功能和结构。 在此的示例中,我们将打印Hello World
到MS-DOS命令提示符。
> echo "Hello World"
电源外壳 (PowerShell)
Powershell is the next generation programming and scripting language used by Windows operating systems. It has some basic support for Linux platform too. PowerShell has bindings with programming languages like C# and Visual Basic.Net. In this example, we will print Hello World
to the screen.
Powershell是Windows操作系统使用的下一代编程和脚本语言。 它也对Linux平台提供一些基本支持。 PowerShell具有与C#和Visual Basic.Net等编程语言的绑定。 在此示例中,我们将在屏幕上打印Hello World
。
PS> Write-Output "Hello World"
Perl (Perl)
Perl is an old friend of Unix and Linux system administrators. As it is not so much popular currently there are popular applications developed with Perl. We can print Hello World
to the terminal in a Perl script like below.
Perl是Unix和Linux系统管理员的老朋友。 由于目前还不太流行,因此有一些用Perl开发的流行应用程序。 我们可以使用下面的Perl脚本将Hello World
打印到终端。
#!/usr/bin/perl
print "Hello World"
PHP (PHP)
PHP is a web-oriented programming language. PHP is designed as scripting language like Python. We can also use PHP as a system scripting language. We will print Hello World
in this example.
PHP是一种面向Web的编程语言。 PHP被设计为像Python这样的脚本语言。 我们还可以将PHP用作系统脚本语言。 在此示例中,我们将打印Hello World
。
#!/usr/bin/php
echo "Hello World"
shell bash脚本