echo命令详解

echo命令是Linux中最基础和最常用的命令,此处对echo命令的常用方法进行总结。

输入:

[root@node1 ~]# echo ifconfig

输出:

ifconfig

输入:

[root@node1 ~]# echo `ifconfig`

输出:

bond0: flags=5443<UP,BROADCAST,RUNNING,PROMISC,MASTER,MULTICAST> mtu 1500 inet 172.16.1.11 netmask 255.255.255.0 broadcast 172.16.1.255 inet6 fe80::379b:2fcf:2a40:4294 prefixlen 64 scopeid 0x20<link> ether f8:75:88:4f:37:c1 txqueuelen 1000 (Ethernet) RX packets 23834607 bytes 3045446631 (2.8 GiB) RX errors 0 dropped 5501762 overruns 0 frame 0 TX packets 11197377 bytes 1908949712 (1.7 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp2s0f0: flags=6467<UP,BROADCAST,RUNNING,PROMISC,SLAVE,MULTICAST> mtu 1500 ether f8:75:88:4f:37:c1 txqueuelen 1000 (Ethernet) RX packets 18238011 bytes 2319807642 (2.1 GiB) RX errors 0 dropped 1 overruns 0 frame 0 TX packets 319792 bytes 40208148 (38.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0x92f00000-92ffffff enp2s0f1: flags=6467<UP,BROADCAST,RUNNING,PROMISC,SLAVE,MULTICAST> mtu 1500 ether f8:75:88:4f:37:c1 txqueuelen 1000 (Ethernet) RX packets 5615052 bytes 734538233 (700.5 MiB) RX errors 0 dropped 1 overruns 0 frame 0 TX packets 10888928 bytes 1869951941 (1.7 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0x92e00000-92efffff enp2s0f2: flags=4355<UP,BROADCAST,PROMISC,MULTICAST> mtu 1500 ether f8:75:88:4f:37:c3 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0x92d00000-92dfffff enp2s0f3: flags=4355<UP,BROADCAST,PROMISC,MULTICAST> mtu 1500 ether f8:75:88:4f:37:c4 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device memory 0x92c00000-92cfffff enp4s0f0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500 inet 10.200.101.131 netmask 255.255.255.0 broadcast 10.200.101.255 inet6 fe80::fa75:88ff:fe87:9ba8 prefixlen 64 scopeid 0x20<link> ether f8:75:88:87:9b:a8 txqueuelen 1000 (Ethernet) RX packets 529678037 bytes 158899597018 (147.9 GiB) RX errors 0 dropped 6620845 overruns 0 frame 0 TX packets 400156944 bytes 112065246274 (104.3 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp4s0f1: flags=4355<UP,BROADCAST,PROMISC,MULTICAST> mtu 1500 ether f8:75:88:87:9b:a9 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 370521565 bytes 706047283678 (657.5 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 370521565 bytes 706047283678 (657.5 GiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

输入:

[root@node1 ~]# echo "`ifconfig`"

输出:

bond0: flags=5443<UP,BROADCAST,RUNNING,PROMISC,MASTER,MULTICAST>  mtu 1500
        inet 172.16.1.11  netmask 255.255.255.0  broadcast 172.16.1.255
        inet6 fe80::379b:2fcf:2a40:4294  prefixlen 64  scopeid 0x20<link>
        ether f8:75:88:4f:37:c1  txqueuelen 1000  (Ethernet)
        RX packets 23836462  bytes 3045681786 (2.8 GiB)
        RX errors 0  dropped 5502194  overruns 0  frame 0
        TX packets 11198207  bytes 1909044016 (1.7 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s0f0: flags=6467<UP,BROADCAST,RUNNING,PROMISC,SLAVE,MULTICAST>  mtu 1500
        ether f8:75:88:4f:37:c1  txqueuelen 1000  (Ethernet)
        RX packets 18239421  bytes 2319984808 (2.1 GiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 319817  bytes 40211248 (38.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x92f00000-92ffffff  

enp2s0f1: flags=6467<UP,BROADCAST,RUNNING,PROMISC,SLAVE,MULTICAST>  mtu 1500
        ether f8:75:88:4f:37:c1  txqueuelen 1000  (Ethernet)
        RX packets 5615497  bytes 734596222 (700.5 MiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 10889733  bytes 1870043145 (1.7 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x92e00000-92efffff  

enp2s0f2: flags=4355<UP,BROADCAST,PROMISC,MULTICAST>  mtu 1500
        ether f8:75:88:4f:37:c3  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x92d00000-92dfffff  

enp2s0f3: flags=4355<UP,BROADCAST,PROMISC,MULTICAST>  mtu 1500
        ether f8:75:88:4f:37:c4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0x92c00000-92cfffff  

enp4s0f0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST>  mtu 1500
        inet 10.200.101.131  netmask 255.255.255.0  broadcast 10.200.101.255
        inet6 fe80::fa75:88ff:fe87:9ba8  prefixlen 64  scopeid 0x20<link>
        ether f8:75:88:87:9b:a8  txqueuelen 1000  (Ethernet)
        RX packets 529711971  bytes 158916672735 (148.0 GiB)
        RX errors 0  dropped 6621364  overruns 0  frame 0
        TX packets 400174659  bytes 112070758401 (104.3 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp4s0f1: flags=4355<UP,BROADCAST,PROMISC,MULTICAST>  mtu 1500
        ether f8:75:88:87:9b:a9  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 370548991  bytes 706103298390 (657.6 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 370548991  bytes 706103298390 (657.6 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

输入:

[root@node1 cf-monitor]# echo I love bat > cf.txt

输出:

I love bat

输入:

[root@node1 cf-monitor]# echo I love bat too >> cf.txt

输出:

I love bat
I love bat too

输入:

echo "\"It is a test\""

输出:

"It is a test"

 

上一篇:沉淀再出发:java中的equals()辨析


下一篇:【BASH】笔记