tail #显示文件的尾部信息,默认显示文件最后10行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
[root@clf ~]# tail passwd mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin [root@clf ~]# tail -n 1 passwd postfix:x:89:89::/var/spool/postfix:/sbin/nologin === [root@clf ~]# tail -1 passwd postfix:x:89:89::/var/spool/postfix:/sbin/nologin [root@clf ~]# tail -c5 passwd #显示最后5个字符,只能看见4个,另外一个是换行符 ogin [root@qls ~]# [root@clf ~]# tail -f passwd mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin hello #另外一个窗口进行测试 [root@clf ~]# echo 'hello' >> passwd [root@clf ~]# tail -f test.log tail: cannot open ‘test.log’ for reading: No such file or directory tail: no files remaining [root@clf ~]# tail -F test.log tail: cannot open ‘test.log’ for reading: No such file or directory tail: ‘test.log’ has appeared; following end of new file test |