Linux learning-escaping and quoting, arithmetic operations, special symbols, exit

Shell

Escape and quote

  • Special characters
    • "#" Comment, ";" semicolon, "" escape symbol, "" "and" '"double and single quotes
    • "'` The difference between double quotes, single quotes and backticks. Double quotes are not fully quoted and will be interpreted if they contain variables. Single quotes are fully quoted and will not be interpreted if they contain variables. Backquotes are used to execute commands.
    • The characters enclosed in single quotes appear as ordinary characters. When special characters are enclosed in single quotes, they will lose their original meaning and be interpreted as ordinary characters.
    • Characters enclosed in double quotes, except for $, backquotes (`) and backslashes (\) still retain their special functions, the rest of the characters are treated as ordinary characters. "$" Indicates variable substitution; backquotes indicate command substitution;
    • The string enclosed by backticks is interpreted by the shell as a command line. During execution, the shell first executes the command line and replaces the entire backticks (including two backticks) with its standard output.

Arithmetic operation

  • expr 4 + 5 expr only supports integers
  • whether the expression 4 + = `5`
  • ((a = 4 + 5)); echo $ a, double parentheses is equivalent to let command

Special symbol

  • (), Use parentheses alone, will produce a child process. (abc = 123); When echo $ abc is not displayed.
  • [] Used for testing, equivalent to the test command, testing two characters, judging the file type and comparing the number size.
    Such as [5 -gt 4]; echo $?
  • [[]] Double brackets are used for expressions, such as [[5> 4]]; echo $?
  • {}, Used to specify the scope, such as echo {0..9}

Exit and exit commands

  • Exit program command
    • exit
    • exit 10 returns 10 to the shell, if the return value is not 0, it exits abnormally
    • $? Determine whether the previous process of the current shell exited normally
    • The test command is used to check files or compare values

Guess you like

Origin www.cnblogs.com/chenri/p/12677410.html