公司网站年费,婚恋网站建设需求文档,闷声赚钱的10个副业,网站建设手机官网输出重定向 command1 file1 vim test hello cat test who users cat test echo nihao test cat test 输入重定向 command1 file1 wc -l test 统计行数 重定向深入了解 一般情况下#xff0c;每个 Unix/Linux 命令运行时都会打开三个文件 file1 vim test hello cat test who users cat test echo nihao test cat test 输入重定向 command1 file1 wc -l test 统计行数 重定向深入了解 一般情况下每个 Unix/Linux 命令运行时都会打开三个文件 标准输入文件(stdin)stdin的文件描述符为0Unix程序默认从stdin读取数据。标准输出文件(stdout)stdout 的文件描述符为1Unix程序默认向stdout输出数据。标准错误文件(stderr)stderr的文件描述符为2Unix程序会向stderr流中写入错误信息。 默认情况下command file 将 stdout 重定向到 filecommand file 将stdin 重定向到 file。 如果希望 stderr 重定向到 file可以这样写 command 2 file 如果希望 stderr 追加到 file 文件末尾可以这样写 command 2 file 如果希望将 stdout 和 stderr 合并后重定向到 file可以这样写 command file 21 command file 21 如果希望对 stdin 和 stdout 都重定向可以这样写 command file1 file2 Here Document Shell 中的一种特殊的重定向方式用来将输入重定向到一个交互式 Shell 脚本或程序。 command delimiter document delimiter 它的作用是将两个 delimiter 之间的内容(document) 作为输入传递给 command。 注意 结尾的delimiter 一定要顶格写前面不能有任何字符后面也不能有任何字符包括空格和 tab 缩进。开始的delimiter前后的空格会被忽略掉。wc -l EOF欢迎来到 菜鸟教程 www.runoob.com EOF cat EOF
欢迎来到
菜鸟教程 www.runoob.com EOF /dev/null文件 如果希望执行某个命令但又不希望在屏幕上显示输出结果那么可以将输出重定向到 /dev/null command /dev/null /dev/null 是一个特殊的文件写入到它的内容都会被丢弃如果尝试从该文件读取内容那么什么也读不到。但是 /dev/null 文件非常有用将命令的输出重定向到它会起到禁止输出的效果。 如果希望屏蔽 stdout 和 stderr可以这样写 command /dev/null 21转载于:https://www.cnblogs.com/DowneyJr/p/7659412.html