当前位置: 首页 > Linux

linux重定向与管道符号

时间:2023-04-06 06:40:56 Linux

重定向与管道符号重定向功能:将命令的执行结果输出到指定文件,而不是直接显示在屏幕上0标准输入键盘stdin只读1标准输出终端stdout只写2到standarderrorterminalstderronlywrites3+filenameotherfilesread/writeLinux内置一个进程,带有编号标记的通道(文件m描述符)来管理打开的文件文件数据操作重定向标准输出1>(1可以省略)输出执行命令结果到指定文件而不是显示在屏幕上,覆盖history>history.txtfind/-userruochen>history.txt1>>(1可以省略)标准输出,添加ls>>history.txtredirectstandard错误输出2>保存标准错误信息到指定文件,覆盖find/-userruochen2>error.txt2>>保存标准错误信息保存错误信息到指定文件,另外写入find/-userruochen2>>error.txtfind/-userruochen>true.txt2>false.txtredirectstandardoutputandstandarderroroutput&>overwrite&>>Appendwrite将所有标准输出和标准错误保存到指定文件中find/-userruochen&>a.txtfind/-userruochen&>>a.txtfind/-userruochen>>true.txt2>/dev/null管道:传输标识符|就是把管道前面的输出作为后面语句statement1|的条件执行格式声明2|...语句ncasels-l/usr/bin|羊肚菌|wc-l>/tmp/根目录-t|head-n10>/tmp/rootdir查找/-nameroot|找到-size+10k|查找大小+100k