Aaron, Thank you for the time and comments posted. All valid and I have replied in-line. On 30/12/14 15:19, Anton Aylward wrote:
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"
Thanks, man page read and understood to some extent. As I mentioned to Luuk, whilst \ indicates that the command is not finished and continues on the next line, my command of :~> find $HOME/Maildir -type d | egrep -v "/new"\|"/cur"\|"/tmp"\|"/courie*" |sort > /home/hylton/maillistdir was entered on one line in Terminal despite spilling over to two lines, had no backslashes, why? The above command executed without error. My Terminal is 72 x 21 and I do not understand where to place the backslash i.e. before/after pipes redirection etc. OR did I use them i.e. after "/new", "/cur" and "/tmp" but not after "/courie*"?
As earlier posing wrote
find $HOME/Maildir -type d -print|\ grep -Ev
If you read the man page section I referred to it says
man page read, re-read and noted as a starting point before scripting again. :)
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.
But are they needed given the above command executed fine despite being more then one line long?
Just as a side issue, in situation like this I use 'egrep' but then I'm one of the Greybeard Brigade.
NP, as from the man page <quote> egrep is the same as grep -E. </quote>
2. The backtick is a command pipe. See the BASH man page on COMMAND SUBSTITUTION
Seems <quote> $>man bash </quote> is going to be VERY WELL read :) <snip>
A bit of RTFM and a bit of experimentation with each command separately would have uncovered a lot.
I would agree, however in my own defence knowing what to look up in the man pages is always a good starting point :)
KISS.
There is no need for the braces.
and my learning continues :) <snip>
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.
My 2c: Double quotes are better because it seems single quotes can be acted upon inside them whereas they cannot if enclosed in single quotes.
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.
Lets not but rather concentrate on learning to code cli commands so that they give us the correct answers we seek.
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.
Guess the only one to not play with is # rm / :) Thanks for info and time and knowledge gained. I cannot promise to remember it all but hopefully the links will remain as to where to find the necessary information. Regards Hylton -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org