Shell Learning Notes

Source: Internet
Author: User
Tags case statement echo command

Shell Learning Notes1, View/etc/shells, see how many shells are available.2, a command that has been used exists. Bash_history, but ~/The . Bash_history records All instructions recorded before the previous login and is successfully logged out before being stored in the. bash_history. 5, man bash to view bash documentation. 6, Echo $7, variable settings, single and double quotation marks are different: double quotation marks can still retain the contents of the variable, the single quotation mark can only be ordinary characters, there will be no special symbol. 8, anti-single quotes ' symbol: In a sequence of instructions, the instruction within the ' will be executed first, and the result of its execution will be the external input content. 9、Set: Displays the variables within bash. Ten, $: Represents the current executor code (PID) of the shell. The number that echo $$ appears is the PID number.  One、? : The value returned from the previous instruction. 0 or not 0 value: Echo $? A, the current CPU of the PC is divided into: +/64 bits, of which 32 bits i386, i586, i686, and 64 bits are called x86_64.  -, the subroutine inherits only the environment variables of the parent program, and does not inherit the parent program's custom variables.  -, export variable name: Share your own variable set to the program that was started later.  the, Locale: Changes the environment variable to a custom variable.  -, read: Reading keyboard variables -, declare, typeset: Defining Variable Types -, restricting some system resources for users: Ulimit +, #: The shortest one in line with the substituted text -, # #: The longest match to replace the text +、%: Delete variable contents from behind A, command alias definition: Alias,unalias (example: define alias lm='Ls-al | more') at, historical commands: History -, bash Shell's operating Environment: example: Setting the echo command is called Echo-N, and then observe the order of the Echo execute: [[email protected]~]# alias echo='Echo-n'[Email protected] ~]# type-a Echoecho isaliased to ' echo-n'Echo is a shell Builtinecho Is/bin/echolook at that! It's clear! Alias, then builtin, and $PATH find it./bin/Echo!  -, Bash's pit welcome message:/etc/issue,/etc/MOTD -, login shell settings for the overall environment:/etc/ Profile -, Source: command to read environment settings -, Default bash settings: ~/. BASHRC in, Bash Shell combo key: Combine keys to perform results Ctrl+C Finally the current command CTRL+D Enter the end of the bundle (EOF), such as when the email is finished; Ctrl+M is Enter! Ctrl+S Pause screen to output CTRL+Q Restore the output of the screen Ctrl+you delete the entire column of commands under prompt character Ctrl+Z "Pause" the current order -, special symbols: symbolic meaningsRepresentative0to infinitely many "arbitrary characters?on behalf of "There must be an" any character [] in the same way as "there must be a character in parentheses" (non-arbitrary characters). For example [ABCD] stands for "must have a character, may be a, B, C, d these four any one" [-] If there is a minus in the parentheses, it represents "all characters in the code sequence." For example0-9] Represents0To9all the numbers in between, because the numbers of the language code is continued! [^] If the first character in the parentheses is the number symbol (^), it means "reverse selection", for example [^ABC] representative must have a character, as long as the non-A, B, C of the other characters to accept the meaning. Symbol # notation: This is most commonly used in script, and is seen as stating! The subsequent information does not perform the jump break: the "special character or Universal character" is also the original general character|pipe (pipe): Delimit the definition of two command lines (next two episodes);; Continuity instruction delimiter: definition of continuity command (note!) Not the same as the command line)~User's home records $ takes a variable pre-character: that is, the number of variables needed to replace the value before the change&Job Control: Turn the instructions into a background work!logically the meaning of "not" does not mean! /Identifier : path-delimited symbols, >>Information Flow redirection: Output direction, divide is "replace" and "accumulate"<, <<Information Flow redirection: Input direction (these two are left to the next section)' 'Single- cited, does not have the function of changing the conversion" "It has the function of changing the conversion! The "Two" ' "" is a command that can be executed first, or a $ () () in the middle of the beginning and end of the child shell {} in the middle of the order block!  to,/dev/NULLGarbage bin Black hole +, EOF: Enter this keyword, end immediately, no input required [ctrl]+D -, > and >> the, the judgment basis of the order execution:; , && | | *, Cut, grep: Pick command $, sort commands: Sort, WC, uniqPanax Notoginseng, Tee -, Character conversion command: Tr,col,join.paste,expand the, Split command: Split +, parameter substitution: Xargs AMinus sign"-"the use of4If you read a enter sign (CR), you try to start executing the line command,5If you have too many rows, you can use \ to extend to the next line,6) # can be used as annotations. 1, >without a command in front of file, the shell creates an empty file (0 characters long) and loses its contents if the file has existed before. 2, you can type more than one command in a row, and the commands are separated by semicolons. 3, if you type a command followed by A &symbol, the command is sent to the background execution, that is, the command no longer occupies the terminal, you can continue to handle other work. 4, the $ character is the special character of the shell, and if it is followed by a valid variable name, the shell treats it as an instruction to replace it with the value stored in the variable here. An expression can be written as $ (expression). 5, the shell variable $#, which contains the number of arguments typed in the command line. 6, $*you can refer to all the parameters passed to the program, which is often useful in programs where parameters are indeterminate or the number of parameters is variable. 7."[email protected]"It will be replaced with "$n", where [email protected] The double quotation marks are essential, if not, the variables [email protected] and $*exactly the same. 7, if you want to pass more than 9 arguments to a program, you cannot use the $Ten, $11 method to take the 10th and later parameters, to use ${n} this format. 8, the shell automatically sets the exit state of the last executed command to the shell variable $?the. $CP Phonebook Phone2 $echo $?     $00 Operation succeeded Non 0 operation failed9, internal command test, which is used to test one or several conditions in the IF command, in the format test expression. -Nstringdetect string is not NULL for true-Nstringanother pattern for detecting a string null as a true test command [expression]-eq equals-GE is greater than or equal-GT greater than-Le is less than or equal-LT is less than-ne is not equal to file judgment-d for Directory-e exists-F Common Files-R readable File-s length is not 0-W writable file-x executable file-L link file logical judgment!Logical Non--a logic and-o Logical ORTen, parentheses format () One, Else structureifCommand1 then commandElsecommand fi A, internal command exit it can immediately terminate the execution of the shell program. Exit n N is the exit state that you want to return, not specified as the exit state of the last command.  -, elif structureifCommand1 then command elif command2 then commandElsecommand fi -, Case structure CaseValueinchpat1) Command command;     PAT2) command command;     ... patn) Command command ... *specifies the matching pattern for special characters in the ESAC Case statement:?represents any one character* Denotes 0 or several arbitrary characters one, and the last "*" indicates the default mode, when the variable cannot be matched by using the preceding modes, "*) "Command sequence after.  the、-x Debug program options SH-x Program Name program parameters -, empty command: Its purpose is to do nothing, more for conditional statements -, && and | |structure&& If you write Command1 in any location that requires a shell command &&Command2 executes the Command1 first if the returned exit status is 0, and if Command1 returns an exit state of 0, the Command2 is skipped. ||The structure function is similar, except that the second command is executed only if the exit status of the first command is not 0 o'clock. In the left and right sides of this structure can be used pipe line.  If used on the left, the exit status of the last command in the pipe line is detected.  -, for command for var inchWord1 Word2 ... wordn/filenames[1-n]/$* DoCommand command ... done +, while command whileCommand1 DoCommand command ... done whileOften used in conjunction with the SHIFT command. The shift command moves the positional variable down (that is, $n to $n-1), and $ #递减.  -, until command until Command1 DoCommand command ... done in contrast to while mode +, sleep N program hangs n seconds,'s'  forSeconds (Thedefault),       'm'  forminutes,'h'  forhours,'D'  forDays . A、 BreakNContinueN exits from N-tier loops at, the directory that the shell searches for when the PATH executes the command, separated from each other by a colon {:} -EXEC command EXEC program replaces the current application with a new shell

Shell Learning Notes

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.