Linux Sysadmin Basics 04 -- Shell Features -- Pipes and Redirection

  • command1 | command2

    The output of one command is stored and then passed as the input for second command.

ps aux | less

  • three channels
    • STDIN —— 0
    • STDOUT —— 1
    • STDERR —— 2
  • output redirection
    • command > file : overwrite
    • command >> file : append
  • input redirection
    • command < file
  • error redirection
    • command 2> file
    • command 2>> file
echo "this should be in a file" 1> test.txt  # "1" can be ignored since it is the default
echo "this should be line 2" >> test.txt
mail -s "this is the subject" dave < message.txt
ls -alh thereisnosuchdir 2> err.txt

  • ps [options]

    report a snapshot of the current processes.

posted @ 2021-01-26 21:38  Blind  阅读(46)  评论(0编辑  收藏  举报