LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-22-2022, 09:57 PM   #1
lqchoo
LQ Newbie
 
Registered: Jan 2021
Posts: 6

Rep: Reputation: Disabled
How to exclude a list of patterns when running du


I have a list of pattern that I want to exclude when running du.

> du --exclude-from EXCLUDE.TXT myfolder/

How should I add these patterns to the EXCLUDE.TXT file?

-/myfolder/...randomsubfolderlevel.../sub/*.gz
-/myfolder/...randomsubfolderlevel.../sub3/
-/myfolder/...randomsubfolderlevel../sub1/file1
-/myfolder/...randomsubfolderlevel.../sub2/sub1a/*_file1.txt
-/myfolder/...randomsubfolderlevel.../sub2/sub2/newlog_*/folder1/
-/myfolder/...randomsubfolderlevel.../sub2/sub2a/oldlog_*/file1
-/myfolder/...randomsubfolderlevel.../sub2/sub2a/subfolder/oldfolder_*/
 
Old 05-23-2022, 12:32 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Frankly, this looks like absolute beginner level homework to me.

First of all, I don't think any of this will work for lines that start with a '-' (minus).

Then, are you asking us how to add lines of text to a file? You can use your favorite editor, or sth like 'echo "blabla" >> file' or 'cat' etc. etc.

Or are you asking about the pattern? Read 'man du', skip to PATTERNS.

Quote:
Originally Posted by lqchoo View Post
I have a list of pattern that I want to exclude when running du.

> du --exclude-from EXCLUDE.TXT myfolder/

How should I add these patterns to the EXCLUDE.TXT file?

-/myfolder/...randomsubfolderlevel.../sub/*.gz
-/myfolder/...randomsubfolderlevel.../sub3/
-/myfolder/...randomsubfolderlevel../sub1/file1
-/myfolder/...randomsubfolderlevel.../sub2/sub1a/*_file1.txt
-/myfolder/...randomsubfolderlevel.../sub2/sub2/newlog_*/folder1/
-/myfolder/...randomsubfolderlevel.../sub2/sub2a/oldlog_*/file1
-/myfolder/...randomsubfolderlevel.../sub2/sub2a/subfolder/oldfolder_*/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Search multiple patterns & print matching patterns instead of whole line Trd300 Linux - Newbie 29 03-05-2012 07:41 PM
--exclude-from=FILE excluding patterns complications cucolin@ Linux - Server 7 04-06-2007 12:35 PM
Exclude certain patterns from grep? kinetik Linux - General 4 04-24-2006 05:37 AM
tar --exclude --exclude-from cefn Linux - Software 4 10-11-2005 07:31 PM
Remembering patterns and printing only those patterns using sed bernie82 Programming 5 05-26-2005 05:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration