linux shell基础-1
# 输出重定向">"、">>" # 输出重定向,然后用追加重定向增加内容cat /etc/passwd > ./passwd
echo "this is a new line" >> ./passwd
# 用tail命令查看最后三行内容,找到新增内容
tail -3 ./passwd
test:x:500:500::/home/test:/bin/bash
su-test:x:501:501::/home/su-test:/bin/bash
this is a new line
# 追加重定向会覆盖文件原内容
echo "this is only content will leave" > ./passwd
cat ./passwd
this is only content will leave
# 输入重定向"list.log 2>&1
cat list.log
ls: cannot access i_am_not_exist: No such file or directory
-rw-r--r-- 1 root root 934 May6 22:37 stdin-redirect
# 把错误信息输出到系统黑洞
# 将错误信息或正确信息输入到黑洞
ls stdddd
ls: cannot access stdddd: No such file or directory
ls stdddd 2> /dev/null
页:
[1]