On Tue, 30 Dec 2014 10:10, Hylton Conacher (ZR1HPC)
On 29/12/14 19:03, Yamaban wrote:
On Mon, 29 Dec 2014 17:42, Hylton Conacher (ZR1HPC)
wrote: Hi,
I am endeavouring to print a list of my Maildir folders to a file so that I can use that same list when I construct a Procmailrc file.
Initially I ran ~> find $HOME/Maildir -type d -print | sort > /home/hylton/maillistdir
**sample snip*** /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari/courierimapkeywords /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari/cur /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari/new /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari/tmp ********
I noticed that there were many sub-folders I did not need. Given this list ended up being 273pg, after a short stint at editing it I decided there had to be a way to exclude certain folders.
What I need is the namesand paths of the folders ie /home/hylton/Maildir/.INBOX.A-F.Bookstores.Kalahari
, not the /cur, /tmp, /new or even the /courierimapkeywords sub-folders.
So far I have:
~> find $HOME/Maildir -type d \( ! -name tmp \) -o \( ! -name cur \) -o \( ! -name new \) -o \( ! -name courierimapkeywords \) | -print | sort > /home/hylton/maillistdir
Please do yourself a favior and use more simple than less and thus more complex tools. Grep is your friend.
[code] find $HOME/Maildir -type d -print|\ grep -Ev '/(courierimapkeywords|cur|new|tmp)$' |\ sort > /home/hylton/maillistdir [/code]
Thank you. I was thinking of nesting the various folders I want to exclude in a grep query. Unfortunately although I used your code:
:~> find $HOME/Maildir -type d -print|\grep -Ev `/{courierimapkaeywords|new|tmp|cur)$' |\sort > /home/hylton/maillistdir
it only gave me a > and seemed to be waiting input whereas all te others have just completed and returned me to a $> prompt?
Ok, multiple errors here. 1. mixed quotation marks. You start with a 'backtick' and end with a 'single quote'. 'backticks` are for enclosed commands e.g. [code] echo `date` [/code] showns the output of the date -command. 'single quote' means the enclosed text is given to the command without any interpretation by the shell. Further info: see 'man bash' and search for quoting. 2. mixed brackets. You start with a 'opening curly bracket' and end with a 'closing round bracket'. 'curly brackets' have a complete different meaning (repeat of a search pattern), than 'square brackets', which mean different chars at this possition, or 'round brackets' in combination with 'pipe symbol' / 'vertical slash' which are for mutliple search-pattern in this position. Further info: "man grep" and search for 'Character Classes' and 'Bracket Expressions' correct command in one line: [code] find $HOME/Maildir -type d | grep -Ev '/(courierimapkeywords|cur|new|tmp)$' | sort > /home/hylton/maillistdir [/code] details: 1. for the find command, the 'default last option' is '-print' and can be left off. 2. for the grep command, using only 'single quote' and 'round brackets' is the key to success. 3. the sort command is clear, but be aware that different 'LANG' and 'LC_ALL' settings can influence the sorting order. Cheers, - Yamaban -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org