मुझे लगता है की आदेश का उपयोग करें, उदाहरण के लिए:क्यों "{} " की आवश्यकता है?
find . -name "*.log" -exec grep "running" {} \;
क्यों की कमान लगता है {}
, एक खाली और \
की ज़रूरत है?
मुझे लगता है की आदेश का उपयोग करें, उदाहरण के लिए:क्यों "{} " की आवश्यकता है?
find . -name "*.log" -exec grep "running" {} \;
क्यों की कमान लगता है {}
, एक खाली और \
की ज़रूरत है?
यह -exec
पैरामीटर की वजह से है: {}
फ़ाइल के लिए प्लेसहोल्डर है जो कमांड को पास किया जाएगा। इस तरह \;
-exec
काम करता है:
अर्धविराम (;
) find
बताता है कि -exec
तर्क सूची खत्म हो गया है, लेकिन ;
के बाद भी एक खोल ऑपरेटर है, आप इसे से बचने के लिए इतना है कि यह find
तक पहुँच जाता है की जरूरत के लिए प्रत्येक फ़ाइल जो मिली है, -exec
(कमांड) के बाद पहला तर्क निष्पादित किया गया है और ;
तक सभी पैरामीटर कमांड के तर्क के रूप में पास किए जाते हैं। {}
को तब वर्तमान फ़ाइल नाम से प्रतिस्थापित किया जाता है जो find
द्वारा पाया जाता है।
{}
पथ के लिए प्लेसहोल्डर है, जो find
वास्तविक पाए गए पथ के साथ प्रतिस्थापित करता है।
\;
खोज exec
तर्कों को समाप्त करता है। \
खोल के बिना इसे खोल स्टेटमेंट टर्मिनेटर के रूप में माना जाएगा, इसलिए इसे के साथ ;
पास करने के लिए खोलने के लिए इसे उद्धृत करने की आवश्यकता है।
मैं कहूंगा कि ;
find
exec
कमांड टर्मिनेटर के लिए दुर्भाग्यपूर्ण विकल्प था।
ध्यान दें कि {} \;
अनुक्रम {} +
साथ बदला जा सकता:
-exec command {} +
This variant of the -exec action runs the specified command on
the selected files, but the command line is built by appending
each selected file name at the end; the total number of invoca‐
tions of the command will be much less than the number of
matched files. The command line is built in much the same way
that xargs builds its command lines. Only one instance of `{}'
is allowed within the command. The command is executed in the
starting directory.
बस manpages
-exec command ;
Execute command; true if 0 status is returned. All following
arguments to find are taken to be arguments to the command until
an argument consisting of `;' is encountered. The string `{}'
is replaced by the current file name being processed everywhere
it occurs in the arguments to the command, not just in arguments
where it is alone, as in some versions of find. Both of these
constructions might need to be escaped (with a `\') or quoted to
protect them from expansion by the shell. See the EXAMPLES sec‐
tion for examples of the use of the -exec option. The specified
command is run once for each matched file. The command is exe‐
cuted in the starting directory. There are unavoidable secu‐
rity problems surrounding use of the -exec action; you should
use the -execdir option instead.
बैकस्लैश पढ़ गलत व्याख्या किए जाने से अर्धविराम की रक्षा के लिए एक भागने है। ब्रेसिज़ प्लेसधारक हैं जो खोज द्वारा आउटपुट किए गए पूर्ण पथ के लिए हैं।