{"id":122607,"date":"2018-10-08T08:37:29","date_gmt":"2018-10-08T00:37:29","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=122607"},"modified":"2018-09-30T19:37:50","modified_gmt":"2018-09-30T11:37:50","slug":"background-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/background-linux.html","title":{"rendered":"\u5982\u4f55\u5728\u4e24\u4e2a\u76ee\u5f55\u4e2d\u5220\u9664\u5176\u4e2d\u4e00\u4e2a\u76ee\u5f55\u4e2d\u540c\u540d\u6587\u4ef6"},"content":{"rendered":"
\u5047\u8bbe\u73b0\u5728\u6709\u4e00\u4e2a\u76ee\u5f55\/mnt\/data\uff0c\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u76ee\u5f55\/opt\/data\uff0c\u9700\u8981\u5220\u9664\/opt\/data\u76ee\u5f55\u4e2d\u548c\/mnt\/data\u76ee\u5f55\u4e2d\u7684\u540c\u540d\u6587\u4ef6\u3002
\n\u5de7\u5999\u505a\u6cd5\uff1a\u5229\u7528xargs<\/p>\n
[root@centos6-vm01 ~]# ll \/mnt\/data\/\r\ntotal 0\r\n-rw-r--r--. 1 root root 0 Jan 10 23:24 anhui\r\n-rw-r--r--. 1 root root 0 Jan 10 23:24 bobo\r\n-rw-r--r--. 1 root root 0 Jan 10 23:17 huihui\r\n \r\n[root@centos6-vm01 ~]# ll \/opt\/data\/\r\ntotal 0\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 beijing\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 bobo\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 huihui\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 shanghai\r\n <\/pre>\n\u6b63\u786e\u505a\u6cd5\uff1a<\/strong><\/div>\n\u6ce8\u610f\uff0c\u4e0b\u9762\u547d\u4ee4\u4e2d\u7684\/mnt\/data\u540e\u9762\u4e0d\u80fd\u52a0\/\uff0c\u800c\/opt\/data\/\u540e\u9762\u9700\u8981\u52a0\/<\/p>\n
[root@centos6-vm01 ~]# cd \/mnt\/data && ls -p | grep -v \/$ | xargs -I{} rm -f \/opt\/data\/{}\r\n[root@centos6-vm01 data]#<\/pre>\n\u6216\u8005\uff1a<\/p>\n
[root@centos6-vm01 ~]# cd \/mnt\/data && ls -p | grep -v \/$ | xargs -t -I{} rm -f \/opt\/data\/{}\r\nrm -f \/opt\/data\/anhui\r\nrm -f \/opt\/data\/bobo\r\nrm -f \/opt\/data\/huihui\r\n[root@centos6-vm01 data]#<\/pre>\n\u89e3\u91ca\uff1a<\/strong><\/div>\nls -p \u53c2\u6570\u5c06\u7ed9\u5217\u51fa\u7684\u76ee\u5f55\u540d\u6700\u540e\u52a0\u4e0a\/\r\ngrep -v \u53c2\u6570\u6307\u5b9a\u53cd\u9009\u62e9\uff0c \/$\u6307\u5b9a\u4ee5\/\u7ed3\u5c3e\u7684\u641c\u7d22\u6a21\u5f0f\uff0c\u56e0\u6b64\u8be5\u547d\u4ee4\u5c06\u8f93\u51fa\u4e0d\u5e26\/\u7ed3\u5c3e\u7684\u9879\uff0c\u4e5f\u5c31\u662f\u53ea\u8f93\u51fa\/opt\/test_a\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u540d\uff0c\u4e0d\u5305\u542b\u5b50\u76ee\u5f55\u3002\r\nxargs\u547d\u4ee4\u7684-I{} \u6307\u5b9a\u7528\u7ba1\u9053\u4f20\u9012\u8fc7\u6765\u7684\u8f93\u5165\u66ff\u6362\u540e\u9762\u547d\u4ee4\u4e2d\u7684{}\u5b57\u7b26\u4e32\uff0c\u91cd\u590d\u591a\u6b21\uff0c\u76f4\u81f3\u7ba1\u9053\u6ca1\u6709\u8f93\u5165\r\n\u6ce8\uff1axargs\u52a0\u4e0a -t \u53c2\u6570\uff0c\u53ef\u4ee5\u770b\u5230\u66ff\u6362\u7684\u6548\u679c<\/pre>\n\u68c0\u67e5\u4e00\u4e0b\uff0c\u53d1\u73b0\u4e0a\u9762\u547d\u4ee4\u6267\u884c\u540e\uff0c\/opt\/data\u76ee\u5f55\u4e0b\u7684\u540c\u540d\u6587\u4ef6\u5df2\u7ecf\u5220\u9664\u4e86<\/p>\n
[root@centos6-vm01 data]# ll \/mnt\/data\/\r\ntotal 0\r\n-rw-r--r--. 1 root root 0 Jan 10 23:24 anhui\r\n-rw-r--r--. 1 root root 0 Jan 10 23:24 bobo\r\n-rw-r--r--. 1 root root 0 Jan 10 23:17 huihui\r\n[root@centos6-vm01 data]# ll \/opt\/data\/\r\ntotal 0\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 beijing\r\n-rw-r--r--. 1 root root 0 Jan 10 23:25 shanghai<\/pre>\n\n\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/www.cnblogs.com\/kevingrace\/p\/8268690.html<\/a><\/p>\n