Shell Initial involvement

Source: Internet
Author: User

I. Concept:

The shell, commonly known as the shell (used to distinguish it from the kernel), is a command-line interpreter that receives user commands and then invokes the appropriate application.


Two. Type of shell:

1. SH (Bourne Shell): Developed by Steve Bourne, various Unix systems are equipped with SH

2. CSH (C Shell): Developed by Bill Joy, with the BSD UNIX release, its process control statements are much like the C language and support many features that the Bourne Shell does not support: Job control, Command history, command-line editing.
3. Ksh (Korn Shell): Developed by David Korn, backwards compatible with SH, and added the new features introduced by CSH, are the most current UNIX system standard configuration of the shell, on these systems/bin/sh often point to/bin/ The symbolic link of the ksh.
4. TCSH (Tenex C Shell): is an enhanced version of CSH, the introduction of command completion, in the FreeBSD, Mac OS X and other systems to replace the CSH.
5. Bash (Bourne Again shell): The shell developed by GNU, the main goal is to be consistent with the POSIX standard, while taking into account the compatibility of SH, bash from CSH and Ksh learn a lot of features, is A variety of Linux distribution standard configuration of the shell, on the Linux system/bin/sh is often a symbolic link to/bin/bash. However, bash and SH are a lot different, on the one hand, bash expands some commands and parameters, on the other hand, bash is not completely compatible with SH, some behaviors are inconsistent, so bash needs to simulate the behavior of SH: When we start bash with the program name SH, bash can Pretend that you are sh, do not recognize the extended command, and the behavior is consistent with SH.


Three. Shell running process:

Linux environment, the computer will run bash when you turn on the computer. When we enter the terminal, Bash creates a child in the current directory

Shell (to prevent a malicious command from making bash error). When we enter a command, the child shell detects whether it is a built-in command, if it is, executes directly, if it is not a built-in command, but a normal command, the child shell creates a child process that is exec in the subprocess

The binary file for this command (but if it is not a binary file, but a text file, and the first line is Shebang (#! /BIN/SH) specifies an interpreter, the code of the EXEC interpreter program in the child process, and executes from the _start of the interpreter, and the text file is passed to the interpreter as a command-line argument).

Ps:shell built-in commands are just a function of the shell process. The shell's built-in commands are viewed with the man bash-builtins command.


Four. Shell variables:

(1). Overview: Shell variables are composed of all caps and underscores, and shell variables are divided into environment variables and local variables.

Environment variables: Environment variables can be passed from the parent process to the child process. You can use the PRINTENV command to display the environment variables for the current shell.

Local variable: exists only in the current shell process. You can use the SET command to display all the variables and functions defined in the current shell process.

PS: Environment variables are available to all processes, while local variables are shell-specific.

Exporting an environment variable is the Export command. (Exprot varname=value) (Export environment variables and define environment variables can be completed in one step).

Delete the defined environment variable or local variable with the unset command.


(2). Variable references:

If a variable is called VARNAME, use ${varname} to represent its value, and $varname to represent its value without causing ambiguity.

such as Echo ${valname}


(3). File name substitution:

The following characters for matching are called wildcards (Wildcard), as follows:
*: Match 0 or more of any characters
? : Matches an arbitrary character
[Several characters]: matches one occurrence of any character in square brackets

Example: There are bash.c bbsh.c bcsh.c bdsh.c files

Then the LS *.c will display all. c files

LS B?SH.C will show all the files above

LS b[abc]sh.c will display bash.c bbsh.c bcsh.c file


(4).

This article is from "Narcissus" blog, please make sure to keep this source http://10704527.blog.51cto.com/10694527/1789659

Shell Initial involvement

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.