天天看点

Linux 终端输入并保存至指定文件

tee命令

tee - read from standard input and write to standard output and files

SYNOPSIS
   tee [OPTION]... [FILE]...

DESCRIPTION
   Copy standard input to each FILE, and also to standard output.

   -a, --append
          append to the given FILEs, do not overwrite

   -i, --ignore-interrupts
          ignore interrupt signals

   --help display this help and exit

   --version
          output version information and exit
           

EXAMPLE:

ifconfig | tee hello.txt

ens33: flags=<UP,BROADCAST,RUNNING,MULTICAST>  mtu 
        inet .  netmask .  broadcast .
        inet6 fe80::c41b:c61:ec8:f5  prefixlen   scopeid <link>
        ether :0c::bb:c9:ad  txqueuelen   (Ethernet)
        RX packets   bytes  ( KiB)
        RX errors   dropped   overruns   frame 
        TX packets   bytes  ( KiB)
        TX errors   dropped  overruns   carrier   collisions 

lo: flags=<UP,LOOPBACK,RUNNING>  mtu 
        inet ..  netmask ..
        inet6 ::  prefixlen   scopeid <host>
        loop  txqueuelen   (Local Loopback)
        RX packets   bytes  (. B)
        RX errors   dropped   overruns   frame 
        TX packets   bytes  (. B)
        TX errors   dropped  overruns   carrier   collisions 
           

cat hello.txt

ens33: flags=<UP,BROADCAST,RUNNING,MULTICAST>  mtu 
        inet .  netmask .  broadcast .
        inet6 fe80::c41b:c61:ec8:f5  prefixlen   scopeid <link>
        ether :0c::bb:c9:ad  txqueuelen   (Ethernet)
        RX packets   bytes  ( KiB)
        RX errors   dropped   overruns   frame 
        TX packets   bytes  ( KiB)
        TX errors   dropped  overruns   carrier   collisions 

lo: flags=<UP,LOOPBACK,RUNNING>  mtu 
        inet ..  netmask ..
        inet6 ::  prefixlen   scopeid <host>
        loop  txqueuelen   (Local Loopback)
        RX packets   bytes  (. B)
        RX errors   dropped   overruns   frame 
        TX packets   bytes  (. B)
        TX errors   dropped  overruns   carrier   collisions 
           

实现了终端与文件的输出

继续阅读