[Linux] The study of the shell

Source: Internet
Author: User
Tags echo command

  1. What is a shell?

    Shell is a use C Programming language, which is used by the user Linux the bridge. the Shell is both a command language and a programming language.

    Shell refers to an application that provides an interface through which users access the service of the operating system kernel.

    Ken Thompson of the SH is the first kind Unix Shell , Windows Explorer is a typical graphical interface Shell .

  2. Shell script

    Shell Scripts ( Shell Script ), is a Shell the script that was written.

    What the industry says Shell Shell script, but we want to know that the shell shell script

    For reasons of habit, brevity, this article appears the shell Programming " It's all meant Shell scripting does not refer to developing Shell themselves.

  3. Shell Environment

    shell Span style= "font-family: Song Body" > programming with Java , php programming, as long as there is a text editor that can write code and a script interpreter that can explain execution.

    linux Shell

  • Bourne Shell ( /usr/bin/sh or /bin/sh )
  • Bourne Again Shell ( /bin/bash )
  • C Shell ( /usr/bin/csh )
  • K Shell ( /usr/bin/ksh )
  • Shell for Root ( /sbin/sh )

The above types of shells are specifically differentiated as follows:

  1. sh ( full name Bourne Shell) : is unix originally used shell And in each UNIX can be used.
    Bourne Shell in shell very good programming, but not in dealing with the user's interaction with other kinds of Span style= "Font-family:helvetica" > shell
  2. bash Span style= "font-family: Arial" > (full name Bourne Again Shell " : Linuxos default, it is Bourne Shell Bourne Shell fully compatible, and in Bourne Shell C Shell Korn Shell has the advantages of flexible and powerful editing interface, but also a friendly user interface.
  3. csh ( Span style= "font-family: Arial" > full name C Shell) : is a more than Bourne Shell more suitable variant Shell C The language is very similar.
  4. Tcsh : is Linux provides the C Shell
    Tcsh includes command line editing, programmable word completion, spelling correction, Historical command substitution, job control and similar to C The grammar of the language, he not only and Bash Shell prompt is compatible, and also provides more than Span style= "Font-family:helvetica" > Bash Shell more prompt parameters.
  5. ksh ( Span style= "font-family: Arial" > full name Korn Shell) : assembled C Shell " and Bourne Shell and is fully compatible with Bourne Shell
  6. pdksh: is an extension of the Ksh provided by the Linux system . Pdksh supports character control, which can be suspended on the command line, executed in the background, awakened or terminated by the program.
  1. Create a shell script

    Use the touch or Text Editor Vi/vim command in the folder to create a new script with an. sh extension, such as test.sh.

    Note that the extension does not affect script execution, but be aware of the name.

    Enter the first line of code.

      1. #!/bin/bash
      2. echo "Hello world!"   

    Among them,#! is a contract tag that tells the system what interpreter the script needs to execute, even if it uses a shell;

    The echo command is used to output text to a window.

    To run the shell:

    1. As an executable program:

      After saving the code, go to the appropriate directory and execute the following command

      chmod u+x ./test. SH # causes script to have Execute permission

      ./test. SH # Execute script

      Note, be sure to write ./test.sh, but not test.sh , run other binary programs as well, write directlytest.sh,LinuxThe system will goPATHTo find out if it's calledtest.sh, and only/bin,/sbin,/usr/bin,/usr/sbinwait inPATH, your current directory is usually not inPATH, so writetest.shyou're not going to find a command../test.shtell the system that it is looking in the current directory.

    2. As an interpreter parameter

      This works by running the interpreter directly, which is the file name of the shell script:

      /bin/sh test.sh

      Running the script this way does not require the first line of the word to specify the interpreter information.

[Linux] The study of the shell

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.