Shell programming 2 basic functions

alias command
1, check the alias taken by the naming under linux alias
2, take the alias for the command alias l='ls -CF'


One, Bash shortcut key
   ctrl+c forcibly terminate the current command Execute
   ctrl+l to clear the screen
   ctrl+u delete Or cut the command entered before the cursor
   ctrl+k Delete or cut the command entered after the cursor
   ctrl+y Paste the command entered by ctrl+u or ctrl+k
   ctrl+r Search for the previously entered command
   ctrl+d Exit the current terminal
   ctrl+ a Move the cursor to the beginning of the command line ctrl+e Move the cursor to the end of the command line


2. Standard input and output (output redirection)
   1. In the linux environment, everything is a file, so including the keyboard and display belong to the file
     device device file name file descriptor type
     keyboard /dev/stdin 0 standard input
     display /dev/stdout 1 standard output (correct output)
     display /dev/stderr 2 standard error output
  
   2, output redirection (no more input to the original screen), main The function is to output logs for administrators to view and analyze
     Command > file The command result overwrites the content of the
     file Command >> file The command result does not overwrite the content in the file to append

  3, the error command output is redirected (no longer input to the original screen), the main function is to output the log for administrators View analysis
     error command 2> file command overwrite the content of the file
     error command 2>> file command does not overwrite the content of the file to append
 
4, the correct error command is also saved in a file
    fixed format: command &> file name or command & >> File name

5, the command &>/dev/null
    null is a special file, a trash file, meaningless command results can be saved under this null

6, the correct output results and wrong commands are saved in two files respectively Among them,
    command >> file 1 2 >> file 2


3, standard input and output (input redirection), usually 1 is used when patching
   , the wc command
      wc -c counts the number of bytes wc -w counts the number of words wc -l Count the number of lines
  
   2, command < file
      such as: wc -l<a.jsp Count how many lines are in the a.jsp file

4 , execute multiple commands in sequence
   1, ; command 1 ; command 2 ; command 3 There is nothing between the 3 commands Relation
   2,&& Command 1 && Command 2 When command 1 is executed correctly, command 2 will be executed, otherwise command 2 will not be executed
   3,|| Command 1 || Command 2 When command 1 is not executed correctly, command 2 will be executed. When command 1 is executed correctly, command 1 will not be executed.

   4.dd execute copy disk file
     dd if=input file of=output file bs= File byte count=how many file bytes

5 , pipe character
    1, command 1|command 2
       takes the correct output of command 1 as the operation object of command 2 (note: there must be correct output)


6, wildcard
   ? Represents a character
   * Represents 0 or more characters

Seven , other symbols
    '' All special symbols in single quotes have no meaning, such as $'$a'
    , all special symbols in double quotes have meaning, such as "$ a" It means to take the value of
    variable a`` Backticks are to refer to system variables such as `date`, which has the same effect as $(date)


    




Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327039268&siteId=291194637