ITPub博客

首页 > 数据库 > Oracle > [20180302]使用find命令小错误.txt

[20180302]使用find命令小错误.txt

原创 Oracle 作者:lfree 时间:2018-03-02 15:51:49 0 删除 编辑

[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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2151445/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4017
  • 访问量
    7997566