linux下file命令使用技巧
1. windows以不同的擴展名來區分不同的文件,例如:.exe .png等
2. linux下對擴展名沒有明確的要求有時就會遇到各種坑,當我們不知道是一個壓縮文件,用一些命令查看的時候,會出現各種亂碼
[[email protected] ~]# cat text |head Y諦8о+ub.°@¤q:%DURr)Xs弱±O§萞L泏d2§滲2c
3. 用file來查看文件類型
[[email protected] ~]# file text
text: gzip compressed data,from Unix, last modified: Wed Aug 23 23:10:14 2017
[[email protected] ~]#
4. 由此可以看出,這是個壓縮文件,可以使用,tar -tf查看
[[email protected] ~]# tar -tftext
etc/services
[[email protected] ~]#
5. 對於一沒有擴展名的文件,可以用file查看文件類型
[[email protected] ~]# file /bin/ls /etc/hosts ser.tar.gz
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1(SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
/etc/hosts: ASCIItext
ser.tar.gz: gzipcompressed data, from Unix, last modified: Wed Aug 23 23:10:14 2017
[[email protected] ~]#
本文出自 “13091780” 博客,請務必保留此出處http://13101780.blog.51cto.com/13091780/1960896
linux下file命令使用技巧