[20180302]使用find命令小错误.txt
--//上午一台机器磁盘空间爆满,腾出磁盘空间顺便清理adump目录文件,再次遇到小问题.做一个记录.
--//我使用find遇到的问题还不少,链接:http://blog.itpub.net/267265/viewspace-2147455/
1.删除aud文件:
$ cd /u01/app/oracle/admin/xxxx/adump
$ find . -name *.aud
-bash: /usr/bin/find: Argument list too long
$ ls -l *.aud
-bash: /bin/ls: Argument list too long
--//开始很疑惑,马上明白*.aud在bash shell上展开.
$ ls -l "*.aud"
ls: *.aud: No such file or directory
--//报错.
$ find . -name "*.aud" -exec file {} \+
find: file: Argument list too long
find: file: Argument list too long
find: file: Argument list too long
./ora_19536.aud: ASCII English text
./ora_1918.aud: ASCII English text
./ora_14603.aud: ASCII English text
--//文件太多,使用+号也不行.必须使用find+xargs命令.
2.继续:
--//顺便测试如何更快删除.
$ time find . -name "*.aud" | xargs file |wc
20507 82028 758759
real 0m5.494s
user 0m5.005s
sys 0m0.275s
$ time find . -name "*.aud" | xargs -P 5 file |wc
20507 82032 758759
real 0m2.278s
user 0m5.032s
sys 0m0.317s
$ time find . -name "*.aud" | xargs -P 5 rm -f
real 0m0.724s
user 0m0.030s
sys 0m0.575s
--//205xx文件,1秒删除.
3.看看参数最大多少:
$ getconf ARG_MAX
131072
--//我仅仅看到一台centos 6.5
# getconf ARG_MAX
2621440