linux查找大文件命令
其實很多時候,你需要了解當(dāng)前系統(tǒng)下有哪些大文件,那么如何通過命令查找出來呢?下面由學(xué)習(xí)啦小編為大家整理了linux查找大文件的命令的相關(guān)知識,希望對大家有幫助!
1.linux查找大文件命令——find命令
例如我要搜索當(dāng)前目錄下,超過800M大小的文件
[root@getlnx01 u03]# pwd
/u03
[root@getlnx01 u03]# find . -type f -size +800M
顯示結(jié)果:
./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
./oradata/epps/invsubmat_d08.dbf
./oradata/epps/gmtinv_d08.dbf
./oradata/epps/gmtinv_x01.dbf
./oradata/epps/undotbs02.dbf
./oradata/epps/gmtinv_d07.dbf
./oradata/epps/undotbs01.dbf
./oradata/epps/gmtinv_x02.dbf
如上命令所示,我們僅僅能看到超過800M大小的文件的文件名稱,但是對文件的信息(例如,文件大小、文件屬性)一無所知,那么能否更詳細(xì)顯示一些文件屬性或信息呢,當(dāng)然可以,如下所示
[root@getlnx01 u03]# find . -type f -size +800M -print0 | xargs -0 ls -l
顯示結(jié)果:
-rw-r----- 1 oracle oinstall 2782846976 Mar 6 11:51 ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
-rw-r----- 1 oracle oinstall 1878433792 Mar 6 11:53 ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
-rw-r----- 1 oracle oinstall 1378492416 Mar 6 11:54 ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
-rw-r----- 1 oracle oinstall 1641381888 Mar 6 11:56 ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
-rw-r----- 1 oracle oinstall 1564065792 Mar 6 11:58 ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
-rw-r----- 1 oracle oinstall 1663492096 Mar 6 12:00 ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
-rw-r----- 1 oracle oinstall 1368244224 Mar 6 12:02 ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
-rw-r----- 1 oracle oinstall 1629069312 Mar 6 12:04 ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
-rw-r----- 1 oracle oinstall 1629954048 Mar 6 12:06 ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
-rw-r----- 1 oracle oinstall 1202192384 Mar 6 12:07 ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
-rw-r----- 1 oracle oinstall 1189388288 Mar 6 12:10 ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
-rw-r----- 1 oracle oinstall 1089257472 Mar 6 12:11 ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
-rw-r----- 1 oracle oinstall 1097687040 Mar 6 12:12 ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
-rw-r----- 1 oracle oinstall 1051009024 Mar 6 12:13 ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
-rw-r----- 1 oracle oinstall 4294975488 Apr 3 15:07 ./oradata/epps/gmtinv_d07.dbf
-rw-r----- 1 oracle oinstall 4194312192 Apr 1 22:36 ./oradata/epps/gmtinv_d08.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr 3 15:54 ./oradata/epps/gmtinv_x01.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr 3 15:57 ./oradata/epps/gmtinv_x02.dbf
-rw-r----- 1 oracle oinstall 4294975488 Apr 1 22:35 ./oradata/epps/invsubmat_d08.dbf
-rw-r----- 1 oracle oinstall 8589942784 Apr 4 09:55 ./oradata/epps/undotbs01.dbf
-rw-r----- 1 oracle oinstall 8589942784 Apr 4 09:15 ./oradata/epps/undotbs02.dbf
當(dāng)我們只需要查找超過800M大小文件,并顯示查找出來文件的具體大小,可以使用下面命令
[root@getlnx01 u03]# find . -type f -size +800M -print0 | xargs -0 du -h
顯示結(jié)果:
1.3G ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.1G ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.2G ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.2G ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.5G ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.1G ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
1.3G ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1004M ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
2.6G ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
4.1G ./oradata/epps/invsubmat_d08.dbf
4.0G ./oradata/epps/gmtinv_d08.dbf
4.1G ./oradata/epps/gmtinv_x01.dbf
8.1G ./oradata/epps/undotbs02.dbf
4.1G ./oradata/epps/gmtinv_d07.dbf
8.1G ./oradata/epps/undotbs01.dbf
4.1G ./oradata/epps/gmtinv_x02.dbf
如果你還需要對查找結(jié)果按照文件大小做一個排序,那么可以使用下面命令
[root@getlnx01 u03]# find . -type f -size +800M -print0 | xargs -0 du -h | sort -nr
顯示結(jié)果:
1004M ./flash_recovery_area/backup/backupsets/ora_df873524162_s46823_s1
8.1G ./oradata/epps/undotbs02.dbf
8.1G ./oradata/epps/undotbs01.dbf
4.1G ./oradata/epps/invsubmat_d08.dbf
4.1G ./oradata/epps/gmtinv_x02.dbf
4.1G ./oradata/epps/gmtinv_x01.dbf
4.1G ./oradata/epps/gmtinv_d07.dbf
4.0G ./oradata/epps/gmtinv_d08.dbf
2.6G ./flash_recovery_area/backup/backupsets/ora_df873513413_s46809_s1
1.8G ./flash_recovery_area/backup/backupsets/ora_df873514789_s46810_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873520789_s46817_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873519953_s46816_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873518302_s46814_s1
1.6G ./flash_recovery_area/backup/backupsets/ora_df873516500_s46812_s1
1.5G ./flash_recovery_area/backup/backupsets/ora_df873517396_s46813_s1
1.3G ./flash_recovery_area/backup/backupsets/ora_df873519197_s46815_s1
1.3G ./flash_recovery_area/backup/backupsets/ora_df873515765_s46811_s1
1.2G ./flash_recovery_area/backup/backupsets/ora_df873522876_s46820_s1
1.2G ./flash_recovery_area/backup/backupsets/ora_df873521714_s46818_s1
1.1G ./flash_recovery_area/backup/backupsets/ora_df873523646_s46822_s1
1.1G ./flash_recovery_area/backup/backupsets/ora_df873523321_s46821_s1
有時候排列的順序并不完全是按大小一致,這個是因為du命令的參數(shù)h所致,你可以統(tǒng)一使用使用MB來顯示,這樣就能解決這個問題。到這里,這個在Linux系統(tǒng)查找大文件的命令已經(jīng)非常完美了,當(dāng)然如果你還有很多的需求,那么可以在這個命令上做修改、調(diào)整.
2.擴展:linux下查看文件內(nèi)容的命令
查看文件內(nèi)容的命令:
cat 由第一行開始顯示內(nèi)容,并將所有內(nèi)容輸出
tac 從最后一行倒序顯示內(nèi)容,并將所有內(nèi)容輸出
more 根據(jù)窗口大小,一頁一頁的現(xiàn)實文件內(nèi)容
less 和more類似,但其優(yōu)點可以往前翻頁,而且進(jìn)行可以搜索字符
head 只顯示頭幾行
tail 只顯示最后幾行
nl 類似于cat -n,顯示時輸出行號
tailf 類似于tail -f