* [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
@ 2015-04-17 20:57 Tanstaafl
2015-04-17 21:47 ` Todd Goodman
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tanstaafl @ 2015-04-17 20:57 UTC (permalink / raw
To: Gentoo
Hi all,
Ok, this is driving me crazy...
I want to be able to quickly search an entire users Maildir for an email
containing a certain string, but output just the filenames WITH THE
DATE/TIMEs...
So, from the target users top level Maildir:
grep -lr <searchstring> * | xargs ls -lt
^^^ appears to work, and does return results for the cur and new
subdirs, but seems to be ignoring the rest of the Maildirs. Maybe it has
something to do with the fact that they start with dots (ie, .Sent,
.Trash, etc)??
Anyone have any idea why the above doesn't search them all?
Thanks
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-17 20:57 [gentoo-user] grep -lr ignoring subdirs that start with dot (.)? Tanstaafl
@ 2015-04-17 21:47 ` Todd Goodman
2015-04-17 22:02 ` covici
2015-04-17 21:59 ` Neil Bothwick
2015-04-19 11:12 ` Andreas K. Huettel
2 siblings, 1 reply; 7+ messages in thread
From: Todd Goodman @ 2015-04-17 21:47 UTC (permalink / raw
To: gentoo-user
* Tanstaafl <tanstaafl@libertytrek.org> [150417 16:58]:
> Hi all,
>
> Ok, this is driving me crazy...
>
> I want to be able to quickly search an entire users Maildir for an email
> containing a certain string, but output just the filenames WITH THE
> DATE/TIMEs...
>
> So, from the target users top level Maildir:
>
> grep -lr <searchstring> * | xargs ls -lt
>
> ^^^ appears to work, and does return results for the cur and new
> subdirs, but seems to be ignoring the rest of the Maildirs. Maybe it has
> something to do with the fact that they start with dots (ie, .Sent,
> .Trash, etc)??
>
> Anyone have any idea why the above doesn't search them all?
>
> Thanks
Try?
grep -lr <searchstring> * | xargs ls -lta
Maybe?
Todd
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-17 20:57 [gentoo-user] grep -lr ignoring subdirs that start with dot (.)? Tanstaafl
2015-04-17 21:47 ` Todd Goodman
@ 2015-04-17 21:59 ` Neil Bothwick
2015-04-23 11:32 ` Tanstaafl
2015-04-19 11:12 ` Andreas K. Huettel
2 siblings, 1 reply; 7+ messages in thread
From: Neil Bothwick @ 2015-04-17 21:59 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
On Fri, 17 Apr 2015 16:57:49 -0400, Tanstaafl wrote:
> So, from the target users top level Maildir:
>
> grep -lr <searchstring> * | xargs ls -lt
>
> ^^^ appears to work, and does return results for the cur and new
> subdirs, but seems to be ignoring the rest of the Maildirs. Maybe it has
> something to do with the fact that they start with dots (ie, .Sent,
> .Trash, etc)??
>
> Anyone have any idea why the above doesn't search them all?
The shell expands * to the contents of the current directory, excluding
hidden files. It's not grep's doing it is the shell expansion that is
catching you out.
Since you want to search the entire contents f the current directory,
there is no need to pass grep a list of directories (especially not an
incomplete list), use "grep -lr ."
--
Neil Bothwick
Bug: (n.) any program feature not yet described to the marketing
department.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-17 21:47 ` Todd Goodman
@ 2015-04-17 22:02 ` covici
0 siblings, 0 replies; 7+ messages in thread
From: covici @ 2015-04-17 22:02 UTC (permalink / raw
To: gentoo-user
Todd Goodman <tsg@bonedaddy.net> wrote:
> * Tanstaafl <tanstaafl@libertytrek.org> [150417 16:58]:
> > Hi all,
> >
> > Ok, this is driving me crazy...
> >
> > I want to be able to quickly search an entire users Maildir for an email
> > containing a certain string, but output just the filenames WITH THE
> > DATE/TIMEs...
> >
> > So, from the target users top level Maildir:
> >
> > grep -lr <searchstring> * | xargs ls -lt
> >
> > ^^^ appears to work, and does return results for the cur and new
> > subdirs, but seems to be ignoring the rest of the Maildirs. Maybe it has
> > something to do with the fact that they start with dots (ie, .Sent,
> > .Trash, etc)??
> >
> > Anyone have any idea why the above doesn't search them all?
> >
> > Thanks
>
> Try?
>
> grep -lr <searchstring> * | xargs ls -lta
>
> Maybe?
Better use the find command with -exec grep and its arguments. You
will probably need -H if you want to know the filename. The difference
is that find only ignores . and .., but does go over other things
beginning with .
--
Your life is like a penny. You're going to lose it. The question is:
How do
you spend it?
John Covici
covici@ccs.covici.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-17 20:57 [gentoo-user] grep -lr ignoring subdirs that start with dot (.)? Tanstaafl
2015-04-17 21:47 ` Todd Goodman
2015-04-17 21:59 ` Neil Bothwick
@ 2015-04-19 11:12 ` Andreas K. Huettel
2 siblings, 0 replies; 7+ messages in thread
From: Andreas K. Huettel @ 2015-04-19 11:12 UTC (permalink / raw
To: gentoo-user
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Am Freitag, 17. April 2015, 22:57:49 schrieb Tanstaafl:
>
> grep -lr <searchstring> * | xargs ls -lt
>
> ^^^ appears to work, and does return results for the cur and new
> subdirs, but seems to be ignoring the rest of the Maildirs. Maybe it has
> something to do with the fact that they start with dots (ie, .Sent,
> .Trash, etc)??
>
'*' does not match things starting with a dot, your suspicion is correct.
(make a directory with one file in it, try
ls -la
versus
ls -la *
:)
There's a simple solution:
grep -lr <searchstring> . | xargs ls -lt
- --
Andreas K. Huettel
Gentoo Linux developer
dilfridge@gentoo.org
http://www.akhuettel.de/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0
iQJ8BAEBCgBmBQJVM42nXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ0RkJDMzI0NjNBOTIwMDY5MTQ2NkMzNDBF
MTM4NkZEN0VGNEI1Nzc5AAoJEOE4b9fvS1d5S60QALUnG47SWSGLhTvRqjkZOV5N
azVJ2IECtTpfs39abkjIA77lJ0CPFAfBvM6rFMSu2WV4D39jHSRAtCYoq34OgG2s
Vh03CL8igCj6oPqcgmKqnubtpghwetfPf9r+9t5drBiR8oESCiI4J9JZo22aWxkr
f2CMAdXWxDPyGfe/JFT7RBsnNbXn5gNVgIFXzxlIMM3bpiBQXZL6M7IZWrCw9+Sw
a/NpqjcaqzJo13hxeTGGcnUWfVJKOjUAjVs8k8Y+lp68YYSKv30TY90UCziYyFUP
lFjG0ZGY9trz2XPeLzV+Nkds04ISyZVSXGCg6uPLmlQeRxaOEIOVvHUNuJE8ik0A
PsoeChm87uUCgQWV/DuZa2rBUSENNnIM3r8lU/Zh4QTc8fNYmGf80DV+tvvtA4rX
WCwY9wgqaXllDjZce4MM2pBsuQh7crWZU5WvVyMmsFwYYd/8SBv0FI1POU/ze4lr
/3AUDAXQyohY51mwJMbMvOxWNi3gUHjZiIg4LGpV7Uqy4ZMnxb/ezR6wOvJQnKrz
WPpBQXGTG29/oLEhyY/DywA5dspjOoZE+mPG7vuooNM3RucbVH0z+guyDBrei0GL
3fWwbPtTHO7OdgZeM7uO/lCw/W8Wms7r6YWJF+yeZ/DBXkWD+IXAf6toZXV+BJck
f28EWPmh69ldJxyAkfqi
=5+Ts
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-17 21:59 ` Neil Bothwick
@ 2015-04-23 11:32 ` Tanstaafl
2015-04-23 14:45 ` Neil Bothwick
0 siblings, 1 reply; 7+ messages in thread
From: Tanstaafl @ 2015-04-23 11:32 UTC (permalink / raw
To: gentoo-user
On 4/17/2015 5:59 PM, Neil Bothwick <neil@digimed.co.uk> wrote:
> Since you want to search the entire contents f the current directory,
> there is no need to pass grep a list of directories (especially not an
> incomplete list), use "grep -lr ."
Ok, thanks Neil, but this is still not what I'm looking for... here's a
snip of what I got:
> ./user1/Maildir/.Sent/cur/1348064019.M219121P18374.mailhost.com,S=7615,W=7788:2,S
> ./user1/Maildir/.Sent/dovecot.index.cache
> ./user2/Maildir/cur/1348063111.Vfe02Ia7fe0eM242648.mailhost.com:2,S
> ./user2/Maildir/dovecot.index.cache
What I'd like is the output you get with
'grep -ir "searchstring" .'
which includes the line of text from each matching file that contains
the searchstring, like this:
> ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:Name asked me to approve Test PO 12036 this afternoon so she could see
> ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:it in the system. In looking at Test PO 12033 & 12034 they show signed
> ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:by me however I did not approve these test PO's only test PO 12036 - how
> ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S: Name asked me to approve Test PO 12036 this afternoon so she could
but...
What I'd like is for each output line showing the file-hit to be
prefaced with at least the date/time of the file (permissions/owner etc
would be ok too, but I at least need the date/time), like you get when
doing an ls -al...
Is this just not possible?
Thanks again...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
2015-04-23 11:32 ` Tanstaafl
@ 2015-04-23 14:45 ` Neil Bothwick
0 siblings, 0 replies; 7+ messages in thread
From: Neil Bothwick @ 2015-04-23 14:45 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]
On Thu, 23 Apr 2015 07:32:54 -0400, Tanstaafl wrote:
> What I'd like is the output you get with
>
> 'grep -ir "searchstring" .'
>
> which includes the line of text from each matching file that contains
> the searchstring, like this:
>
> > ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:Name
> > asked me to approve Test PO 12036 this afternoon so she could
> > see ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:it
> > in the system. In looking at Test PO 12033 & 12034 they show
> > signed ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:by
> > me however I did not approve these test PO's only test PO 12036 -
> > how ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:
> > Name asked me to approve Test PO 12036 this afternoon so she could
>
> but...
>
> What I'd like is for each output line showing the file-hit to be
> prefaced with at least the date/time of the file (permissions/owner etc
> would be ok too, but I at least need the date/time), like you get when
> doing an ls -al...
Something like this?
for i in $(grep -lr searchstring .);do
ls -l $i
grep -H searchstring $i
done
I'm sure you could format it better using the options from ls.
--
Neil Bothwick
I am McCoy of Bo...Damnit! I'm a doctor, not a collective!
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-04-23 14:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-17 20:57 [gentoo-user] grep -lr ignoring subdirs that start with dot (.)? Tanstaafl
2015-04-17 21:47 ` Todd Goodman
2015-04-17 22:02 ` covici
2015-04-17 21:59 ` Neil Bothwick
2015-04-23 11:32 ` Tanstaafl
2015-04-23 14:45 ` Neil Bothwick
2015-04-19 11:12 ` Andreas K. Huettel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox