shell scripts - and the redirection pipe character

1, the redirect -tr (data input and output)
    procedures = commands (instructions) + data (variables)
    in the program, how the data input and output
   1) Input Data: keyboard - the standard input, but not the only way to input
        echo " 123456 "| passwd --stdin" username " // password
        ./useradd.sh <user.txt // user.txt the redirection file to the useradd.sh
   2) output data: display - standard output, but the output is not the only way.
        LS / etc /> a.txt
        FD file identifier 0-9: classification corresponds to the file
       0: Standard Output
       1: Standard Input
       2: Error input-output
common redirection symbol:
  1) Standard Output
    > coverage redirection
    set -C Close covering the redirection function set + C: recovery
    > | forced redirection    
    >> append redirection
  2) standard input
    <a <b: to perform a to b
    tr replacement file content (tr set1 [set2]) char ( character : a one transducer)
    TR the ABC ABC <
    << The multiple rows of data simultaneously input
  3) Error output
    2> 2 >>
    expansion: no output content, only the output state;
    echo $: a command to determine whether the correct (0 correct, 1-255 other is not correct? )
2, pipeline -tee (one input, two outputs)
    command1 | command2 | Command3 | ......: the results of the previous command to a command to perform
    free -m | grep "^ Mem" | -d Cut '' -f19
    as Free -m | grep "^ Mem" | awk '{3} $ Print'
    TEE /tmp/tee.out // If no file is created, the default file if there is content, will be covered;
exercise:
1) the content of the first 5 rows / etc / passwd file conversion saved as a file in uppercase to /tmp/passwd.out
    head -5 / etc / passwd | tr [az] [AZ]> / tmp / passwd the .out
2) login to the system after the user information on the summary of information into the current three saved as a file in uppercase to /tmp/who.out
    who | tail -3 | cut -d ' ' -f1 | tr [az] [AZ] tee /tmp/who.out

tail end of the file to see how many lines (10 lines)
      -n tail -n / etc / passwd == -5 short tail / etc / passwd
      -f file to view real-time updates
      tail -f / var / log / meddage : real-time view the log file
      See file header head how many rows (10 rows)
      # pre -n #,
example: take the / etc / passwd file line 10-20 

head -20 /etc/passwd | tail -10

Guess you like

Origin www.cnblogs.com/hmm01031007/p/11347851.html