shell查找当前目录下大于1M的文件的三种方法分享

(编辑:jimmy 日期: 2024/10/5 浏览:2)

1、使用find的参数实现

复制代码 代码如下:
[root@xiaobb mnt]# find . -maxdepth 1 -size +1000000c
./sys.tar.gz
./install.tar.bz2
./CTeX_2.9.0.152_Full.exe
./php-5.3.6.tar.gz
[root@xiaobb mnt]# ls -lh
total 1.3G
-rw-r--r-- 1 root root 1.1G 2011-04-28 11:35 CTeX_2.9.0.152_Full.exe
drwxr-xr-x 19 root root 12K 2011-04-24 20:28 git
-rw-r--r-- 1 root root 135M 2011-03-18 07:00 install.tar.bz2
drwxrwxrwx 8 flash games 4.0K 2011-04-24 06:38 libevent-1.4.12-stable
-rw-r--r-- 1 root root 488K 2011-04-23 22:46 libevent-1.4.12-stable.tar.gz.gz
drwxr-xr-x 26 root root 4.0K 2011-04-24 21:14 linux-2.6
drwx------ 2 root root 16K 2011-03-10 05:56 lost+found
drwxr-xr-x 10 root root 4.0K 2010-10-22 02:18 mnt
drwxr-xr-x 8 1000 1000 4.0K 2011-04-24 05:51 nginx-0.8.54
-rw-r--r-- 1 root root 635K 2011-04-23 21:12 nginx-0.8.54.tar.gz
drwxr-xr-x 16 1005 1005 4.0K 2011-04-24 07:00 php-5.3.6
-rw-r--r-- 1 root root 14M 2011-04-23 16:04 php-5.3.6.tar.gz
drwxr-xr-x 8 root root 4.0K 2011-04-24 07:02 php-fpm-0.6-5.3.1
-rw-r--r-- 1 root root 415K 2011-04-20 22:08 php-fpm-0.6-5.3.1.zip
drwxr-xr-x 37 root root 4.0K 2011-04-24 20:40 progit
drwxr-xr-x 31 root wheel 4.0K 2011-04-28 05:36 sys
-rw-r--r-- 1 root root 19M 2009-07-13 22:38 sys.tar.gz
[root@xiaobb mnt]#

2、使用ls+awk组合管道
 
复制代码 代码如下:
[root@xiaobb mnt]# find . -maxdepth 1 -size +1000000c;
./sys.tar.gz
./install.tar.bz2
./CTeX_2.9.0.152_Full.exe
./php-5.3.6.tar.gz
[root@xiaobb mnt]# ls -l .|awk '{if($5>1000000) print R$8}'
CTeX_2.9.0.152_Full.exe
install.tar.bz2
php-5.3.6.tar.gz
sys.tar.gz
[root@xiaobb mnt]#

3、使用find+ll+awk组合(管道)

复制代码 代码如下:
[root@xiaobb mnt]# find ./ -name "*" -maxdepth 0 -exec ls -l {} \;|awk '{if($5>1000000) print $8}'
CTeX_2.9.0.152_Full.exe
install.tar.bz2
php-5.3.6.tar.gz
sys.tar.gz
[root@xiaobb mnt]#
[root@xiaobb mnt]# find . -maxdepth 1 -size +1000000c;
./sys.tar.gz
./install.tar.bz2
./CTeX_2.9.0.152_Full.exe
./php-5.3.6.tar.gz

一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。