Linux-admin-tee-command

提供:Dev Guides
移動先:案内検索

Linux Admin-teeコマンド

*tee* は単純なコマンドで、管理者がコマンド出力を記述し、同時にファイルを表示できます。 この単純なコマンドは、最初にstdoutをファイルに書き込んでからファイルの内容を表示する時間を節約できます。

以下は、Tで使用される一般的なスイッチです。

Command Action
-a Append to files instead of clobber file
-i Ignore interrupts (for advanced use in scripting mostly)

/etc内のファイルとディレクトリの表示と書き込みの両方に tee がなければ、それぞれが文字「a」で始まります。

[root@centosLocal Documents]# ls -d/etc/a*
/etc/abrt    /etc/aliases.db   /etc/anacrontab  /etc/at-spi2 /etc/autofs.conf
/etc/auto.master.d /etc/auto.smb /etc/adjtime /etc/alsa     /etc/asound.conf
/etc/audisp        /etc/autofs_ldap_auth.conf /etc/auto.misc /etc/avahi
/etc/aliases /etc/alternatives /etc/at.deny  /etc/audit  /etc/auto.master
/etc/auto.net
[root@centosLocal Documents]# ls -d/etc/a* > ./etc_report_a.txt
[root@centosLocal Documents]# cat ./etc_report_a.txt
/etc/abrt
/etc/adjtime
/etc/aliases
/etc/aliases.db
/etc/alsa
/etc/alternatives
/etc/anacrontab
/etc/asound.conf
/etc/at.deny
/etc/at-spi2
/etc/audisp
/etc/audit
/etc/autofs.conf
/etc/autofs_ldap_auth.conf
/etc/auto.master
/etc/auto.master.d
/etc/auto.misc
/etc/auto.net
/etc/auto.smb
/etc/avahi

[root@centosLocal Documents]#

この小さなタスクは、teeコマンドを使用するとはるかに効率的です。

[root@centosLocal Documents]# ls -d/etc/a* | tee ./etc_report_a.txt
/etc/abrt
/etc/adjtime
/etc/aliases
/etc/aliases.db
/etc/alsa
/etc/alternatives
/etc/anacrontab
/etc/asound.conf
/etc/at.deny
/etc/at-spi2
/etc/audisp
/etc/audit
/etc/autofs.conf
/etc/autofs_ldap_auth.conf
/etc/auto.master
/etc/auto.master.d
/etc/auto.misc
/etc/auto.net
/etc/auto.smb
/etc/avahi

[root@centosLocal Documents]#