linux - Using find to exclude a directory and tar up everything else in a directory -


मैं एक निर्देशिका में निम्नलिखित है:

dir1
dir2
file1
File2

मैं dir1

को छोड़कर सब कुछ छोड़ना चाहता हूं

जब मैं करता हूँ:

  find -पैथ '* dir1 *' -prune -o-print-  

मुझे आउटपुट में डीर 1 (अपेक्षित) नहीं दिख रहा

लेकिन जब मैं करता हूँ: < / P> <पूर्व> ढूंढें -पथ '* dir1 *' -prune -o -exec tar -czvf documents.tgz '{}' \ +

मैं देख रहा हूँ कि dir1 भी documents.tgz में tarred हो जाता है। क्यों? "post-text" itemprop = "text">

यदि "खोज" का उपयोग करना अनिवार्य आवश्यकता नहीं है, तो मान लें कि "main_dir" मूल निर्देशिका नाम के रूप में है ।

  tar --exclude = main_dir / dir1-cvzf tarred_file.gz मुख्य_दिर /    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -