[root@cs7-sm ~]# file /bin/ls #<一像ls命令是一个二进制命令,通过cat命令查看会发现一堆乱码。 /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=ceaf496f3aec08afced234f4f36330d3d13a657b, stripped [root@cs7-sm ~]# od -Ax -tcx /bin/ls|more 000000 177 E L F 002 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0 464c457f 00010102 00000000 00000000 000010 002 \0 > \0 001 \0 \0 \0 324 B @ \0 \0 \0 \0 \0 003e0002 00000001 004042d4 00000000 000020 @ \0 \0 \0 \0 \0 \0 \0 360 303 001 \0 \0 \0 \0 \0 00000040 00000000 0001c3f0 00000000 000030 \0 \0 \0 \0 @ \0 8 \0 \t \0 @ \0 037 \0 036 \0 00000000 00380040 00400009 001e001f 000040 006 \0 \0 \0 005 \0 \0 \0 @ \0 \0 \0 \0 \0 \0 \0 00000006 00000005 00000040 00000000 000050 @ \0 @ \0 \0 \0 \0 \0 @ \0 @ \0 \0 \0 \0 \0 00400040 00000000 00400040 00000000 000060 370 001 \0 \0 \0 \0 \0 \0 370 001 \0 \0 \0 \0 \0 \0 000001f8 00000000 000001f8 00000000
[root@cs7-sm ~]# ls |tee test1 gb2312.txt test1 test2 test_win.sh [root@cs7-sm ~]# cat test1 #<==ls命令接管通和tee命令,在屏靠上输出ls的结果,同时将结果写入到test1.txt。会清空原有的内容 gb2312.txt test1 test2 test_win.sh
[root@cs7-sm ~]# ls |tee -a ls test1 #<==使用参数-a可以追加内容到文件中,不会清空文件中已有的内容。 gb2312.txt ls test1 test2 test_win.sh [root@cs7-sm ~]# cat test1 gb2312.txt test1 test2 test_win.sh gb2312.txt ls test1 test2 test_win.sh
原文:https://www.cnblogs.com/fadewalk/p/10889829.html