基礎命令和管道密切配合使用 tee
基礎命令:tee
tee命令
功能:
把命令1的STDOUT保存在文件名中,然后管道輸入給命令2;
補充說明:tee指令會從標準輸入設備讀取數據,將其內容輸出到標準輸出設備,同時保存成文件。
使用場景:
1.保存不同階段的輸出
2.復雜管道的故障排除
3.同時查看和記錄輸出
語法:
命令1 | tee文件名| 命令2
舉例:
1.舉例:顯示/boot目錄下的文件列表,保存至/tmp/boot_out文件并在屏幕上顯示。
ls -1 /boot | tee /tmp/boot_out #如果不使用tee命令,標準輸出至屏幕或重定向到文件 二者這能選其一 [root@wCentos7 ~]# ls -1 /boot | tee /tmp/boot_out config-3.10.0-327.el7.x86_64 grub grub2 initramfs-0-rescue-2d34ee936fa14412ad51a08dcb36643d.img initramfs-3.10.0-327.el7.x86_64.img initramfs-3.10.0-327.el7.x86_64kdump.img initrd-plymouth.img symvers-3.10.0-327.el7.x86_64.gz System.map-3.10.0-327.el7.x86_64 vmlinuz-0-rescue-2d34ee936fa14412ad51a08dcb36643d vmlinuz-3.10.0-327.el7.x86_64 [root@wCentos7 ~]#
原創文章,作者:linux_root,如若轉載,請注明出處:http://www.www58058.com/27713