The study record of Shell 13 question

Source: Internet
Author: User

On the BBS saw the Shell 13 asked the post, because the comparison is far away, afraid later can not find, put the notes over,

Original address:

Shell 13 Ask
Http://bbs.chinaunix.net/thread-2033675-1-1.html

Post the notes I made:

< a >, why a Shell user communicates with kernel through the shell (the shell of the operating system, the core kernel), which is the shell's naming relationship with kernel. Technically speaking, the simplest definition of the shell is--command interpreter--The default shell for most of the Linux systems that are stored in the system preinstalled by the/etc/shells is bash, for the reason: * Free software * Powerful < two >, Shell prompt (PS1) relationship to carriage Return (CR)? $: For general user account #: Using Shell prompt for the root (Admin) account means simple:The shell tells the user: You can now enter the command line, and the user only has to get the shell prompt to open the command line, and the cursor is a pointer to the keyboardat the command line input, the cursor moves back one cell each time the user enters a key, until the command line is read into the carriage Return character. The meaning of carriage Return is also very simple:the user tells the Shell: Dude, you can execute my command line. Different commands can accept command-line format or have different, in general, a standard command-line format is:command-name Options ArgumentFrom the technical details, the shell will disassemble the text entered by command line according to IFS (Internal field seperator) and then deal with the special character (meta) first, and finally in the reorganization of the entire line command. (Note: Be sure to understand the meaning of the above two sentences, we will often come back to think about it in future study.) Each command line must contain the command name, which is not missing. < three >, others echo, you also echo, is to ask Echo know how much? To take command line described above, here we use echo this command to further explain that the standard command line is full of three parts: Command_name option Argumentecho-e "a\t"   &NB Sp The  -e option is to turn on the backslash control character  < four >, "" (double quotes) and "(single quote) where is the difference? Hard quote: ' single quotes, all system reserved keyword meta in hard quote are closed. Soft quote: "double quotes, in soft quote most of the meta will be closed, some of the eggs are retained (such as $) escape: \ Backslash, only the advanced in the Escape (caret) after the single meta is closed.  < five >, var=value? Where is the difference before and after export? The so-called environment variables are those that pass to the sub-stroke. Hereditary is a decisive indicator for distinguishing local variables from environment variables Var=value assignment only assigns values to local variables export Var=value assigns values to environment variables unset var   cancels var variable, It's not the same as assigning a value to null   < six >, where does exec go with source? Knowing the difference between the parent process and the child process, the parent process produces the child process, and the child process returns to the parent process, which inherits the environment variables of the parent process. Command Script (Shell script): It is to write to a file in a sequence of multiple lines of command line that is normally entered after the shell prompt. Some of these techniques, such as conditional judgments, interactive interfaces, parameter usage, function calls, and so on, allow script to perform smarter.   combines the above two concepts (Process + script), it's not difficult to understand the meaning of the following sentence normally, when we execute a shell script, we actually create a sub-shell child process, and then sub-shell to produce the command line subprocess. In general, the shell script we run is executed with Sub-shell. When you run the script with Subshell? The Workding dir ($PWD) of the sub shell changes because of the CD, but $PWD is not changed when the primary shell is returned.  source so-called source is to have the script execute in the current shell, rather than produce a sub-shell. So as long as we change the script command line that we originally entered into the parameter of the source command, we can easily solve the problem mentioned above./my.sh can become source./my.sh   OR: /my.script exec also lets script execute on the same process, but the original process is ended. This is the biggest difference between exec and source/fork  < seven >, () and {} Where is the difference? Command group: Centralize the processing of multiple commands. () put command group in Sub-shell to execute, also known as nested sub-shell{} is done in the same shell, also known as Non-named command group function is to use a name to Name a command group, and then call this name to execute command group. < eight >, $ (()) and $ () and ${} where is the difference? $ () and ' (anti-quote) are used for command substitution. The so-called command substitution is similar to what we've learned about variable substitution, which is used to reorganize the command line: Complete the command line in quotation marks, then replace the result with the command line.   < nine >, [email protected] and $* where is the difference? [email protected] and $* can get all the parameters of a function in general but when [email protected] and $* are in hard quote that is "", the difference is: [email protected]   will return all parameters to $*   will spell all the parameters into a string return  $#   The total number of parameters can be returned (excluding $, that is, path) ${10}   via ${} You can get more than 10 parameters, otherwise you will be 0 back to  <10>, && and | | Where's the difference? a=123["$A" = 100] can be used to determine whether a is equal to 100 of the format will return a return value, if the return value of 0 is correct, the return value of 1 means that the judgment error after each command is executed by a return value, the same meaning as above ["$A" =] && Amp echo "Yes,\ $A is"     means && the previous return value is ture when executed after ["$A" = 100] | | echo "No,\ $A is not"   means | | When the previous return value is False, you can have more than one command in the following line &&   | | Nested use, such as ["$A" = 100] | | echo "No" && ls-g  && echo "yes"    <11>, 、、、、 the original post was lost .....  <11.1>, stdin and stdout <11.2>, stderr   and how to change the preset data channel for file descriptor   <12> , you want if or case if:# if [[$A = 123]]; then# echo "Oh,yes"# elif [["$A" < 123]]; then#echo "Oh, \ $A > 123"# else#echo "What"# fi Case: # case "$" in#start)#echo "What's start";;#stop)#echo "Hei,that is stop";;#OK)#echo "en, en A";;# Esac <13> for what? Where is the difference between the while and the until? ....

The study record of Shell 13 question

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.