{"id":3854,"date":"2019-07-27T00:02:00","date_gmt":"2019-07-26T16:02:00","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3854"},"modified":"2022-05-18T14:50:53","modified_gmt":"2022-05-18T06:50:53","slug":"xargs","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/xargs","title":{"rendered":"xargs\u547d\u4ee4 – \u7ed9\u5176\u4ed6\u547d\u4ee4\u4f20\u53c2\u6570\u7684\u8fc7\u6ee4\u5668"},"content":{"rendered":"\n
xargs\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201d extended arguments\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u7ed9\u5176\u4ed6\u547d\u4ee4\u4f20\u53c2\u6570\u7684\u8fc7\u6ee4\u5668\u3002xargs\u547d\u4ee4\u80fd\u591f\u5904\u7406\u4ece\u6807\u51c6\u8f93\u5165\u6216\u7ba1\u9053\u7b26\u8f93\u5165\u7684\u6570\u636e\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u6210\u547d\u4ee4\u53c2\u6570\uff0c\u4e5f\u53ef\u4ee5\u5c06\u5355\u884c\u6216\u591a\u884c\u8f93\u5165\u7684\u6587\u672c\u8f6c\u6362\u6210\u5176\u4ed6\u683c\u5f0f\u3002<\/p>\n\n\n\n
xargs\u547d\u4ee4\u9ed8\u8ba4\u63a5\u6536\u7684\u4fe1\u606f\u4e2d\uff0c\u7a7a\u683c\u662f\u9ed8\u8ba4\u5b9a\u754c\u7b26\uff0c\u6240\u4ee5\u53ef\u4ee5\u63a5\u6536\u5305\u542b\u6362\u884c\u548c\u7a7a\u767d\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n
\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong> xargs [\u53c2\u6570] <\/p>\n\n\n\n \u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n \u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n \u9ed8\u8ba4\u4ee5\u7a7a\u683c\u4e3a\u5b9a\u754c\u7b26\uff0c\u4ee5\u591a\u884c\u5f62\u5f0f\u8f93\u51fa\u6587\u4ef6\u5185\u5bb9\uff0c\u6bcf\u884c\u663e\u793a\u4e09\u6bb5\u5185\u5bb9\u503c\uff1a<\/p>\n\n\n\n \u6307\u5b9a\u5b57\u7b26X\u4e3a\u5b9a\u754c\u7b26\uff0c\u9ed8\u8ba4\u4ee5\u5355\u884c\u7684\u5f62\u5f0f\u8f93\u51fa\u5b57\u7b26\u4e32\u5185\u5bb9\uff1a<\/p>\n\n\n\n \u6307\u5b9a\u5b57\u7b26X\u4e3a\u5b9a\u754c\u7b26\uff0c\u4ee5\u591a\u884c\u5f62\u5f0f\u8f93\u51fa\u6587\u672c\u5185\u5bb9\uff0c\u6bcf\u884c\u663e\u793a\u4e24\u6bb5\u5185\u5bb9\u503c\uff1a<\/p>\n\n\n\n \u8bbe\u5b9a\u6bcf\u4e00\u6b21\u8f93\u51fa\u4fe1\u606f\u65f6\uff0c\u90fd\u9700\u8981\u7528\u6237\u624b\u52a8\u786e\u8ba4\u540e\u518d\u663e\u793a\u5230\u7ec8\u7aef\u754c\u9762\uff1a<\/p>\n\n\n\n \u7531xargs\u8c03\u7528\u6267\u884c\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u7ec8\u7aef\u754c\u9762\uff1a<\/p>\n\n\n\n xargs\u547d\u4ee4\u6765\u81ea\u4e8e\u82f1\u6587\u8bcd\u7ec4\u201d extended arguments\u201c\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u7ed9\u5176\u4ed6\u547d\u4ee4 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3854"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=3854"}],"version-history":[{"count":11,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3854\/revisions"}],"predecessor-version":[{"id":9846,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3854\/revisions\/9846"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=3854"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=3854"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=3854"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}-n<\/td> \u591a\u884c\u8f93\u51fa<\/td><\/tr> -d<\/td> \u81ea\u5b9a\u4e49\u4e00\u4e2a\u5b9a\u754c\u7b26<\/td><\/tr> -I <\/td> \u6307\u5b9a\u4e00\u4e2a\u66ff\u6362\u5b57\u7b26\u4e32{}<\/td><\/tr> -t <\/td> \u6253\u5370\u51fa xargs \u6267\u884c\u7684\u547d\u4ee4<\/td><\/tr> -p <\/td> \u6267\u884c\u6bcf\u4e00\u4e2a\u547d\u4ee4\u65f6\u5f39\u51fa\u786e\u8ba4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n [root@linuxcool ~]# cat anaconda-ks.cfg | xargs -n 3<\/strong>\r\n#version=RHEL8 ignoredisk --only-use=sda\r\nautopart --type=lvm #\r\nPartition clearing information\r\nclearpart --all --initlabel\r\n--drives=sda # Use\r\ngraphical install graphical\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026<\/pre>\n\n\n\n
[root@linuxcool ~]# echo \"FirstXSecondXThirdXFourthXFifth\" | xargs -dX<\/strong>\r\nFirst Second Third Fourth Fifth\r<\/pre>\n\n\n\n
[root@linuxcool ~]# echo \"FirstXSecondXThirdXFourthXFifth\" | xargs -dX -n 2<\/strong>\nFirst Second\nThird Fourth\nFifth<\/pre>\n\n\n\n
[root@linuxprobe ~]# echo \"FirstXSecondXThirdXFourthXFifth\" | xargs -dX -n 2 -p<\/strong>\r\necho First Second ?...y<\/strong>\r\nFirst Second\r\necho Third Fourth ?...y<\/strong>\r\nThird Fourth\r\necho Fifth\r\n ?...y<\/strong>\r\nFifth\r<\/pre>\n\n\n\n
[root@linuxcool ~]# ls | xargs -t -I{} echo {}<\/strong>\necho anaconda-ks.cfg \nanaconda-ks.cfg\necho Desktop \nDesktop\necho Documents \nDocuments\necho Downloads \nDownloads\necho initial-setup-ks.cfg \ninitial-setup-ks.cfg\necho Music \nMusic\necho Pictures \nPictures\necho Public \nPublic\necho Templates \nTemplates\necho Videos \nVideos<\/pre>\n","protected":false},"excerpt":{"rendered":"