

























请注意,本文编写于 1690 天前,最后修改于 1416 天前,其中某些信息可能已经过时。
一般情况下,每个 Unix/Linux 命令运行时都会打开三个文件:
默认情况下:
command > file将 stdout 重定向到 filecommand 2 > file将 stderr 重定向到 filecommand < file将stdin 重定向到 file。command > file 2>&1将 stderr 和 stdout合并后重定向到 filecommand > file1 < file2将 stdout 重定向到 file1,stdin 重定向file2command 2 >> file将 stderr 追加到 file末尾
如果希望执行某个命令,但又不希望在屏幕上显示输出结果,那么可以将输出重定向到 /dev/null
command > /dev/null 2>&1屏蔽 stdout 和 stderr
#! /bin/bash if command -v git >/dev/null 2>&1; then echo 'exists git' else echo 'no exists git' fi
#! /bin/bash if type git >/dev/null 2>&1; then echo 'exists git' else echo 'no exists git' fi
#! /bin/bash if hash git 2>/dev/null; then echo 'exists git' else echo 'no exists git' fi
https://www.jianshu.com/p/fbffa5cc49e1 http://c.biancheng.net/cpp/view/2738.html
本文作者:mereith
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。