【linux 文件管理】8-重定向和管道

https://edu.aliyun.com/lesson_1733_14279#_14279

  • 多行重定向
cat > f1 <<a
123
456
a

cat > f1 <<EOF
My hostname is `hostname`
My username is $USER
EOF

mail -s "1st mail" root
hello
how are you
.

mail

  • 管道
    whoami | tr 'a-z' 'A-Z'

cat linux.txt
cat -A linux.txt
cat -A win.txt
hexdump -C linux.txt
hexdump -C win.txt

man ascii
tr --help
tr -d ' ' < win.txt > win2.txt

df | tr -s ' ' %
ls -l /etc | less

  • 管道中 - 符号

  • 重定向到多个目标
    who |tee /data/ls.log 覆盖
    uname -r |tee -a /data/ls.log 追加
    STDERR默认不能通过管道转发,可利用2>&1 或 |& 实现

原文地址:https://www.cnblogs.com/sec875/p/13408654.html