Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)?
Date: Thu, 23 Apr 2015 14:45:50
Message-Id: 20150423154532.3c1ad6a9@digimed.co.uk
In Reply to: Re: [gentoo-user] grep -lr ignoring subdirs that start with dot (.)? by Tanstaafl
1 On Thu, 23 Apr 2015 07:32:54 -0400, Tanstaafl wrote:
2
3 > What I'd like is the output you get with
4 >
5 > 'grep -ir "searchstring" .'
6 >
7 > which includes the line of text from each matching file that contains
8 > the searchstring, like this:
9 >
10 > > ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:Name
11 > > asked me to approve Test PO 12036 this afternoon so she could
12 > > see ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:it
13 > > in the system. In looking at Test PO 12033 & 12034 they show
14 > > signed ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:by
15 > > me however I did not approve these test PO's only test PO 12036 -
16 > > how ./user/Maildir/cur/1429731479.M511050P25876.hostname,S=3097,W=3185:2,S:
17 > > Name asked me to approve Test PO 12036 this afternoon so she could
18 >
19 > but...
20 >
21 > What I'd like is for each output line showing the file-hit to be
22 > prefaced with at least the date/time of the file (permissions/owner etc
23 > would be ok too, but I at least need the date/time), like you get when
24 > doing an ls -al...
25
26 Something like this?
27
28 for i in $(grep -lr searchstring .);do
29 ls -l $i
30 grep -H searchstring $i
31 done
32
33 I'm sure you could format it better using the options from ls.
34
35
36 --
37 Neil Bothwick
38
39 I am McCoy of Bo...Damnit! I'm a doctor, not a collective!