文字、目錄 空間清理問題
阿新 • • 發佈:2021-08-19
1.find
查詢資料夾下依照什麼命名的檔案,並刪除,
注意:
1)當前檔案的話 可以用find .
2)-ok和{}後的空格不能少
[[email protected] log]# find /mnt/work/engine/be-counter/counter-9802/log -type f -name "counter-9802.*.INFO" -ok rm {} \; < rm ... /mnt/work/engine/be-counter/counter-9802/log/counter-9802.1.INFO > ? y [[email protected] log]# [[email protected] log]# [[email protected] log]# ll 總用量 152180 -rw-rw-r-- 1 work work 155670230 3月 4 20:31 counter-9802.INFO [[email protected] log]#
[[email protected] log]# vim counter-9802.1.INFO [[email protected] log]# ll 總用量 152184 -rw-r--r-- 1 root root 6 8月 19 17:34 counter-9802.1.INFO -rw-rw-r-- 1 work work 155670230 3月 4 20:31 counter-9802.INFO [[email protected] log]# find . -type f -name "counter-9802.*.INFO" -ok rm {} \; < rm ... ./counter-9802.1.INFO > ? y [[email protected] log]# ll 總用量 152180 -rw-rw-r-- 1 work work 155670230 3月 4 20:31 counter-9802.INFO
2.檢視檔案的更新時間
stat後是檔名
Modify是建立時間
Access是訪問時間
[[email protected] counter-9802]# stat . File: "." Size: 4096 Blocks: 8 IO Block: 4096 目錄 Device: fc01h/64513d Inode: 5439509 Links: 7 Access: (0775/drwxrwxr-x) Uid: ( 503/ work) Gid: ( 504/ work) Access: 2018-07-13 17:23:17.000000000 +0800 Modify: 2020-12-03 19:22:53.000000000 +0800 Change: 2020-12-03 19:22:53.000000000 +0800
3.檢視目錄下檔案的大小
檢視對應檔案的大小
[[email protected] be-counter]# du -sh ./* 4.0K ./bushu-9803.sh 4.0K ./bushu.sh 361M ./counter-9800 2.2G ./counter-9802 510M ./counter-9803 797M ./counter-9805 471M ./counter-9806
檢視目錄的總大小
[[email protected] be-counter]# du -sh 4.3G .
4.磁碟空間佔用情況
[[email protected] be-counter]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/vda1 296G 132G 150G 47% / tmpfs 2.0G 624M 1.4G 31% /dev/shm