अच्छी तरह से एक चीज़ के लिए -iस्विच को हटा दिया जाता है:
-i[replace-str]
This option is a synonym for -Ireplace-str if replace-str is specified.
If the replace-str argument is missing, the effect is the same as -I{}.
This option is deprecated; use -I instead.
इसलिए जब मैंने आपकी कमान इसके आसपास बदल दी, तो यह काम किया:
$ find /foo/bar -name '*.mp4' -print0 | xargs -I{} -0 mv -t /some/path {}
उदाहरण
$ find . -print0 | xargs -I{} -0 echo {}
.
./.sshmenu
./The GIT version control system.html
./.vim_SO
./.vim_SO/README.txt
./.vim_SO/.git
./.vim_SO/.git/objects
./.vim_SO/.git/objects/pack
./.vim_SO/.git/objects/pack/pack-42dbf7fe4a9b431a51da817ebf58cf69f5b7117b.idx
./.vim_SO/.git/objects/pack/pack-42dbf7fe4a9b431a51da817ebf58cf69f5b7117b.pack
./.vim_SO/.git/objects/info
./.vim_SO/.git/refs
./.vim_SO/.git/refs/tags
...
का उपयोग -I{}
इस कमांड निर्माण को चलाने के बाद से इस दृष्टिकोण का उपयोग नहीं किया जाना चाहिए:
$ find -print0 ... | xargs -I{} -0 ...
अंतर्निहित रूप से इन स्विचों को चालू करता है xargs, -xऔर -L 1। -L 1कॉन्फ़िगर xargsइतना है कि यह आदेशों कॉल कर रहा है तो आप इसे एक भी फैशन में के माध्यम से फ़ाइलें चलाना चाहते हैं।
तो यह xargsयहाँ का उपयोग करने के उद्देश्य को हरा देता है क्योंकि यदि आप इसे 1000 फाइलें देते हैं तो यह mv1000 बार कमांड को चलाने वाला है ।
तो मुझे किस दृष्टिकोण का उपयोग करना चाहिए?
आप इसे इस तरह से xargs का उपयोग करके कर सकते हैं:
$ find /foot/bar/ -name '*.mp4' -print0 | xargs -0 mv -t /some/path
या बस यह सब करना है:
$ find /foot/bar/ -name '*.mp4' -exec mv -t /some/path {} +
"This approach shouldn't be used"किस दृष्टिकोण का उपयोग किया जाना चाहिए? चाहेंगे"find /foot/bar/ -name '*.csv' -print0 | xargs -0 mv -t some_dir'"एक बेहतर समाधान हो? यदि हां, तो कैसे करता हैxargsजहां में इस मामले में पताmvतर्क यह पाइप से हो जाता है में फ़ीड करने के लिए आदेश? (क्या यह हमेशा उन्हें अंतिम स्थान पर रखता है?)