Linux shell及shell脚本概念

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35865125/article/details/87897413

在计算机科学中,Shell俗称壳(用来区别于核),是指“为使用者提供操作接口”的软件(命令解析器)。分为图形界面shell 和 命令行式shell。     “A shell is a program that acts as the interface between you and the Linux system, enabling you to enter commands for the operating system to execute.

Shell作为一种接口软件,有不同的实现,例如上图中的csh, bash都是shell。linux系统中可以同时安装不同的shell,用户可以根据自己的喜好来选择使用哪个。大多数的shell都是从而Bourne shell演化而来的。

On Linux, the standard shell that is always installed as /bin/sh is called bash (the GNU Bourne-Again SHell), from the GNU suite of tools. This is an excellent shell that is always installed on Linux systems, is open source, and is portable to almost all UNIX variants.

On most Linux distributions, the program /bin/sh, the default shell, is actually a link to the program /bin/bash. You can check the version of bash you have with the following command:
$ /bin/bash --version
GNU bash, version 3.2.9(1)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

 

When you create Linux users, you can set the shell that they will use, either when the user is created or afterwards by modifying their details. Figure 2-2 shows the selection of the shell for a user using Fedora.


各种shell总结:


同时它也可指一种程序设计语言。作为命令语言,它交互式解释和执行用户输入的命令或者自动地解释和执行预先设定好的一连串的命令;作为程序设计语言,它定义了各种变量和参数,并提供了许多在高级语言中才具有的控制结构,包括循环和分支。


Unix在最初的时候并没有图形操作界面,所有的命令都是通过命令行来输入的,linux继承了这种命令行的特性。shell在自动执行简单的linux任务方面可以发挥非常大的作用。

One reason to use the shell for programming is that you can program the shell quickly and simply. Moreover, a shell is always available even on the most basic Linux installation, so for simple prototyping you can find out if your idea works.

The shell is also ideal for any small utilities that perform some relatively simple task for which efficiency is less important than easy configuration, maintenance, and portability. You can use the shell to organize process control, so that commands run in a predetermined sequence dependent on the successful completion of each stage.

Although the shell has superficial similarities to the Windows command prompt, it’s much more powerful, capable of running reasonably complex programs in its own right. Not only can you execute commands and call Linux utilities, you can also write them. The shell executes shell programs, often referred to as scripts, which are interpreted at runtime. This generally makes debugging easier because you can easily execute single lines, and there’s no recompile time. However, this can make the shell unsuitable for timecritical or processor-intensive tasks.
 


Ref:

https://baike.baidu.com/item/shell/99702?fr=aladdin

《Beginning Linux Programming》,4th edition

猜你喜欢

转载自blog.csdn.net/qq_35865125/article/details/87897413