[[email?protected] orbit-oracle]# ls |wc -l 1185524 [[email?protected] orbit-oracle]# rm -f * -bash: /bin/rm: Argument list too long [[email?protected] orbit-oracle]# pwd /tmp/orbit-oracle [[email?protected] orbit-oracle]# ls |wc -l 1185524 [[email?protected] orbit-oracle]# ls |xargs rm -f * -bash: /usr/bin/xargs: Argument list too long [[email?protected] orbit-oracle]# ls |wc -l 1185524 [[email?protected] orbit-oracle]# find . -name "*" | xargs rm -rf ‘*‘? rm: cannot remove directory: `.‘ ^C [[email?protected] orbit-oracle]# ls |wc -l 1035696 [[email?protected] orbit-oracle]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 1161190 149530 89% / tmpfs 1007257 738 1006519 1% /dev/shm /dev/xvdd1 19660800 45404 19615396 1% /u01 /dev/xvdc1 9830400 12 9830388 1% /logs /dev/xvdb1 3276800 10559 3266241 1% /app [[email?protected] orbit-oracle]# find . -name "*" | xargs rm -rf ‘*‘? rm: cannot remove directory: `.‘ ^C [[email?protected] orbit-oracle]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 751189 559531 58% / tmpfs 1007257 738 1006519 1% /dev/shm /dev/xvdd1 19660800 45404 19615396 1% /u01 /dev/xvdc1 9830400 12 9830388 1% /logs /dev/xvdb1 3276800 10560 3266240 1% /app [[email?protected] orbit-oracle]# ls |wc -l 625698 [[email?protected] orbit-oracle]#
===============================
http://hi.baidu.com/cpuramdisk/item/5aa49ce00c0757aecf2d4f24
四种办理”Argument list too long”参数列表过长的步伐
在linux中删除大量文件时,直接用rm会呈现:-bash: /bin/rm: 参数列表过长,的错误。
这时可以用find呼吁来团结行使。
例: 1、rm * -rf 改为: find . -name "*" | xargs rm -rf ‘*‘ 就行了。
2、rm test* -rf 改为: find . -name "test*" | xargs rm -rf "test*"
?
mv时报参数列表过长,
for i in *.m;do mv $i ${i%.m};done
于是告急于google,试探进程就省略了,直接说办理要领吧:
ls dir1 | xargs -t -I {} mv {} dir2/{}
这里的一对大括号是原文给的例子里用的,其后看了参数的用法,着实那对大括号是可以用恣意字符串替代的,好比:
ls dir1 | xargs -t -I asdf mv asdf dir2/asdf
结果和大括号那一版是完全一样的,就是看起来有点儿不严重。
必要声名的是,上面xargs的第二个参数,是大写的i,读作”爱“的谁人字母,不是小写的L。至于参数的寄义嘛,我忘了。
?
?
?
?Linux下 报错“呼吁参数列表过长”,在用mv呼吁一次移动3万多个文件时失败了,原始呼吁相同这样:”mv $(ls dir1) dir2“。错误提醒的中心头脑是:”你这参数也太TM多了吧“。
凭证LZ设法或容许以这么做:find /dir1/ -maxdepth 1 | xargs -i mv {} /dir2/ 假如参数过长,行使tar较量简朴 tar -C /dir1/ -cf - . | tar -xf - -C /dir2/
?
于是告急于google,试探进程就省略了,直接说办理要领吧:
ls dir1 | xargs -t -I {} mv {} dir2/{}
这里的一对大括号是原文给的例子里用的,其后看了参数的用法,着实那对大括号是可以用恣意字符串替代的,好比:
ls dir1 | xargs -t -I asdf mv asdf dir2/asdf
结果和大括号那一版是完全一样的,就是看起来有点儿不严重。
必要声名的是,上面xargs的第二个参数,是大写的i,读作”爱“的谁人字母,不是小写的L。至于参数的寄义嘛,我忘了。
?
?
其它4种要领
作为一个linux用户/体系打点员,有些时辰你会碰着以下错误提醒:
?
[[email?protected] foo]$ mv * ../foo2
bash: /bin/mv: Argument list too long
“Argument list too long”参数列表过长错误常常产生在用户在一行简朴呼吁中提供了过多的参数而导致,常常在ls *,cp *,rm * 等中呈现。 按照题目的缘故起因以下提供了四种要领,可以按照本身的环境酌情选用
要领1 : 将文件群手动分别为较量小的组合 e.g 1:
?
[[email?protected] foo]$ mv [a-l]* ../foo2
[[email?protected] foo]$ mv [m-z]* ../foo2
(编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|