On 12/30/2014 04:10 AM, Hylton Conacher (ZR1HPC) wrote:
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 1
`/{courierimapkaeywords|new|tmp|cur)$' |\sort > /home/hylton/maillistdir 234 567 8
The numbers are under characters in the CLI that I have contention with 1. No need for this "". 8. Again. The backslash escape is not needed. RTFM MAN(bash) on "QUOTING" What happened here? As earlier posing wrote find $HOME/Maildir -type d -print|\ grep -Ev If you read the man page section I referred to it says <quote> A non-quoted backslash () is the escape character. It preserves the literal value of the next character that follows, with the exception of <newline>. If a <new-line> pair appears, and the backslash is not itself quoted, the <newline> is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). </quote> That is the backslash is a line continuation character. It means, in the above example, that all the stuff is on one line. Those backquotes should not appear when you do make it into one line. Just as a side issue, in situation like this I use 'egrep' but then I'm one of the Greybeard Brigade. 2. The backtick is a command pipe. See the BASH man page on COMMAND SUBSTITUTION <quote> Command Substitution Command substitution allows the output of a command to replace the command name. There are two forms: $(command) or `command` </quote> As it happens, the backtick is unclosed. The character at "7" does not close it. 3,4,5,6,7 I can't see the reason for this Yes the parameter to grep should be quoted, but that's all. I would have used egrep -v "courierimapkaeywords|new|tmp|cur" A bit of RTFM and a bit of experimentation with each command separately would have uncovered a lot. KISS. There is no need for the braces. What? Oh, I see, there's the "$" meaning that the set has to be at the end of line. The pattern needs to be "(courierimapkaeywords|new|tmp|cur)$" We can now get into an argument about whether on not to use single quotes or double quotes. That matter has used much e-ink on the 'Net and on USENET before it. Read the man page and make up your own mind, but have a reason for it. We can now have an argument over whether the "-E". "-G" or "-e" is needed for that pattern or whether using egrep rather than grep makes that moot. The takeaway from all this is RTFM and KISS Going back over this thread I see that there are some very complicated "find" expressions and the use of a pipe and grep was, true enough, an effort to simplify. But somewhere along the line it got derailed. As far as I'm concerned the wonderful thing about the CLI is that I can build and test commands incrementally, experiment with variations and see what's going on. I'd probably fail an exam since I keep referring back to the man an info pages to make sure. Shell is my favourite language because of this interaction and easy incrementalism. -- /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org