public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] search files for "text string"
@ 2015-06-06 16:45 Joseph
  2015-06-06 17:09 ` Alexander Kapshuk
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Joseph @ 2015-06-06 16:45 UTC (permalink / raw
  To: gentoo-user

I've bunch of php files in many directories and I need to file a text string in them "Check/Money Order"

I've tried:
find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
it doesn't work.

What is a better method of searching files?
-- 
Joseph


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 16:45 [gentoo-user] search files for "text string" Joseph
@ 2015-06-06 17:09 ` Alexander Kapshuk
  2015-06-06 17:46   ` Joseph
  2015-06-06 17:11 ` Philip Webb
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Alexander Kapshuk @ 2015-06-06 17:09 UTC (permalink / raw
  To: Gentoo mailing list

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

On Sat, Jun 6, 2015 at 7:45 PM, Joseph <syscon780@gmail.com> wrote:

> I've bunch of php files in many directories and I need to file a text
> string in them "Check/Money Order"
>
> I've tried:
> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
> it doesn't work.
>
> What is a better method of searching files?
> --
> Joseph
>
>
grep -ls 'Check/Money Order' `du -a | sed '/\.php$/!d;s/.*\t//'` # grep
will complain that the args list is too long if the number of files found
is too great.

Otherwise, this might work for you:

find dir -type f -name \*.php | xargs grep -sl 'Check/Money Order'

[-- Attachment #2: Type: text/html, Size: 1076 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 16:45 [gentoo-user] search files for "text string" Joseph
  2015-06-06 17:09 ` Alexander Kapshuk
@ 2015-06-06 17:11 ` Philip Webb
  2015-06-06 23:40   ` Neil Bothwick
  2015-06-06 21:04 ` Alan McKinnon
  2015-06-07 13:00 ` Volker Armin Hemmann
  3 siblings, 1 reply; 16+ messages in thread
From: Philip Webb @ 2015-06-06 17:11 UTC (permalink / raw
  To: gentoo-user

150606 Joseph wrote:
> I've bunch of php files in many directories
> and I need to find a text string in them "Check/Money Order"

'cd' to the lowest dir which contains them all,
then 'grep -r "Check/Money Order" *.php'.

-- 
========================,,============================================
SUPPORT     ___________//___,   Philip Webb
ELECTRIC   /] [] [] [] [] []|   Cities Centre, University of Toronto
TRANSIT    `-O----------O---'   purslowatchassdotutorontodotca



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 17:09 ` Alexander Kapshuk
@ 2015-06-06 17:46   ` Joseph
  2015-06-06 17:49     ` Alexander Kapshuk
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph @ 2015-06-06 17:46 UTC (permalink / raw
  To: gentoo-user

On 06/06/15 20:09, Alexander Kapshuk wrote:
>   On Sat, Jun 6, 2015 at 7:45 PM, Joseph <[1]syscon780@gmail.com> wrote:
>
>     I've bunch of php files in many directories and I need to file a
>     text string in them "Check/Money Order"
>     I've tried:
>     find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>     it doesn't work.
>     What is a better method of searching files?
>     --
>     Joseph
>
>   grep -ls 'Check/Money Order' `du -a | sed '/\.php$/!d;s/.*\t//'` # grep
>   will complain that the args list is too long if the number of files
>   found is too great.
>   Otherwise, this might work for you:
>   find dir -type f -name \*.php | xargs grep -sl 'Check/Money Order'

Thanks, this worked for me, it searches in current and below dir.

find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'

-- 
Joseph


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 17:46   ` Joseph
@ 2015-06-06 17:49     ` Alexander Kapshuk
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Kapshuk @ 2015-06-06 17:49 UTC (permalink / raw
  To: Gentoo mailing list

[-- Attachment #1: Type: text/plain, Size: 885 bytes --]

On Sat, Jun 6, 2015 at 8:46 PM, Joseph <syscon780@gmail.com> wrote:

> On 06/06/15 20:09, Alexander Kapshuk wrote:
>
>    On Sat, Jun 6, 2015 at 7:45 PM, Joseph <[1]syscon780@gmail.com> wrote:
>>
>>     I've bunch of php files in many directories and I need to file a
>>     text string in them "Check/Money Order"
>>     I've tried:
>>     find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>>     it doesn't work.
>>     What is a better method of searching files?
>>     --
>>     Joseph
>>
>>   grep -ls 'Check/Money Order' `du -a | sed '/\.php$/!d;s/.*\t//'` # grep
>>   will complain that the args list is too long if the number of files
>>   found is too great.
>>   Otherwise, this might work for you:
>>   find dir -type f -name \*.php | xargs grep -sl 'Check/Money Order'
>>
>
> Thanks, this worked for me, it searches in current and below dir.
>
>
>
Good to hear.

[-- Attachment #2: Type: text/html, Size: 1586 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 16:45 [gentoo-user] search files for "text string" Joseph
  2015-06-06 17:09 ` Alexander Kapshuk
  2015-06-06 17:11 ` Philip Webb
@ 2015-06-06 21:04 ` Alan McKinnon
  2015-06-07  3:36   ` Joseph
  2015-06-07 13:00 ` Volker Armin Hemmann
  3 siblings, 1 reply; 16+ messages in thread
From: Alan McKinnon @ 2015-06-06 21:04 UTC (permalink / raw
  To: gentoo-user

On 06/06/2015 18:45, Joseph wrote:
> I've bunch of php files in many directories and I need to file a text
> string in them "Check/Money Order"
> 
> I've tried:
> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
> it doesn't work.
> 
> What is a better method of searching files?


Define "doesn't work" in this context.

My guess is that the string you want isn't actually there.
If it is there, provide a sample of the source text containing the string.

-- 
Alan McKinnon
alan.mckinnon@gmail.com



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 17:11 ` Philip Webb
@ 2015-06-06 23:40   ` Neil Bothwick
  2015-06-07 12:59     ` Volker Armin Hemmann
  0 siblings, 1 reply; 16+ messages in thread
From: Neil Bothwick @ 2015-06-06 23:40 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

On Sat, 6 Jun 2015 13:11:04 -0400, Philip Webb wrote:

> > I've bunch of php files in many directories
> > and I need to find a text string in them "Check/Money Order"  
> 
> 'cd' to the lowest dir which contains them all,
> then 'grep -r "Check/Money Order" *.php'.

That will only search *.php files in the current directory, you need

grep -r --include='*.php' 'Check/Money Order' .

or drop the --include option to search all files. Use single quotes to
stop the shell from trying to interpret anything.


-- 
Neil Bothwick

Why do they call it a TV set when you only get one?

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 21:04 ` Alan McKinnon
@ 2015-06-07  3:36   ` Joseph
  2015-06-07  4:02     ` tlze
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph @ 2015-06-07  3:36 UTC (permalink / raw
  To: gentoo-user

On 06/06/15 23:04, Alan McKinnon wrote:
>On 06/06/2015 18:45, Joseph wrote:
>> I've bunch of php files in many directories and I need to file a text
>> string in them "Check/Money Order"
>>
>> I've tried:
>> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>> it doesn't work.
>>
>> What is a better method of searching files?
>
>
>Define "doesn't work" in this context.
>
>My guess is that the string you want isn't actually there.
>If it is there, provide a sample of the source text containing the string.
>
>-- 
>Alan McKinnon
>alan.mckinnon@gmail.com

Apology, yes it did worked.
I was just in a wrong sub-directory.

-- 
Joseph


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-07  3:36   ` Joseph
@ 2015-06-07  4:02     ` tlze
  0 siblings, 0 replies; 16+ messages in thread
From: tlze @ 2015-06-07  4:02 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 48 bytes --]

try:
find . -type f -exec grep 'abcd'  -l {} \;

[-- Attachment #2: Type: text/html, Size: 101 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 23:40   ` Neil Bothwick
@ 2015-06-07 12:59     ` Volker Armin Hemmann
  2015-06-07 14:30       ` Neil Bothwick
  0 siblings, 1 reply; 16+ messages in thread
From: Volker Armin Hemmann @ 2015-06-07 12:59 UTC (permalink / raw
  To: gentoo-user

Am 07.06.2015 um 01:40 schrieb Neil Bothwick:
> On Sat, 6 Jun 2015 13:11:04 -0400, Philip Webb wrote:
>
>>> I've bunch of php files in many directories
>>> and I need to find a text string in them "Check/Money Order"  
>> 'cd' to the lowest dir which contains them all,
>> then 'grep -r "Check/Money Order" *.php'.
> That will only search *.php files in the current directory, you need

nope

>
> grep -r --include='*.php' 'Check/Money Order' .

not true either.




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-06 16:45 [gentoo-user] search files for "text string" Joseph
                   ` (2 preceding siblings ...)
  2015-06-06 21:04 ` Alan McKinnon
@ 2015-06-07 13:00 ` Volker Armin Hemmann
  2015-06-07 14:40   ` Alan McKinnon
                     ` (2 more replies)
  3 siblings, 3 replies; 16+ messages in thread
From: Volker Armin Hemmann @ 2015-06-07 13:00 UTC (permalink / raw
  To: gentoo-user

Am 06.06.2015 um 18:45 schrieb Joseph:
> I've bunch of php files in many directories and I need to file a text
> string in them "Check/Money Order"
>
> I've tried:
> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
> it doesn't work.
>
> What is a better method of searching files?

grep -R 'whateveryourarelookingfor /path/to/directory/tree/

seriously, why make everything fucking harder with find, when grep alone
can do it for you?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-07 12:59     ` Volker Armin Hemmann
@ 2015-06-07 14:30       ` Neil Bothwick
  0 siblings, 0 replies; 16+ messages in thread
From: Neil Bothwick @ 2015-06-07 14:30 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Sun, 07 Jun 2015 14:59:51 +0200, Volker Armin Hemmann wrote:

> >> 'cd' to the lowest dir which contains them all,
> >> then 'grep -r "Check/Money Order" *.php'.  
> > That will only search *.php files in the current directory, you need  
> 
> nope

The shell expands the *.php to a list of matching files in the current
directory. You need a . to mtch the current directory.


-- 
Neil Bothwick

He who asks a question is a fool for a minute,
He who doesn't ask is a fool for a lifetime.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-07 13:00 ` Volker Armin Hemmann
@ 2015-06-07 14:40   ` Alan McKinnon
  2015-06-08  6:05   ` Raffaele BELARDI
  2015-06-08  6:43   ` Andrew Lowe
  2 siblings, 0 replies; 16+ messages in thread
From: Alan McKinnon @ 2015-06-07 14:40 UTC (permalink / raw
  To: gentoo-user

On 07/06/2015 15:00, Volker Armin Hemmann wrote:
> Am 06.06.2015 um 18:45 schrieb Joseph:
>> I've bunch of php files in many directories and I need to file a text
>> string in them "Check/Money Order"
>>
>> I've tried:
>> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>> it doesn't work.
>>
>> What is a better method of searching files?
> 
> grep -R 'whateveryourarelookingfor /path/to/directory/tree/
> 
> seriously, why make everything fucking harder with find, when grep alone
> can do it for you?
> 


because the youngsters of today think they know everything and lack the
skills to see they know very little

Actually, it's not surprising because strange as it may seem, the skill
to exercise competence is the same skill that recognises it


-- 
Alan McKinnon
alan.mckinnon@gmail.com



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-07 13:00 ` Volker Armin Hemmann
  2015-06-07 14:40   ` Alan McKinnon
@ 2015-06-08  6:05   ` Raffaele BELARDI
  2015-06-08  6:25     ` Alan McKinnon
  2015-06-08  6:43   ` Andrew Lowe
  2 siblings, 1 reply; 16+ messages in thread
From: Raffaele BELARDI @ 2015-06-08  6:05 UTC (permalink / raw
  To: gentoo-user@lists.gentoo.org

Volker Armin Hemmann wrote:
> Am 06.06.2015 um 18:45 schrieb Joseph:
>> I've bunch of php files in many directories and I need to file a text
>> string in them "Check/Money Order"
>>
>> I've tried:
>> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>> it doesn't work.
>>
>> What is a better method of searching files?
>
> grep -R 'whateveryourarelookingfor /path/to/directory/tree/
>
> seriously, why make everything fucking harder with find, when grep alone
> can do it for you?
>

I'm not the OP but I was not able to make 'grep -R' work properly with 
file or directory names containing spaces. I fiddled with IFS but in the 
end I found 'find -print0' was more convenient. Are there better methods 
with grep and shell alone?

raffaele

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-08  6:05   ` Raffaele BELARDI
@ 2015-06-08  6:25     ` Alan McKinnon
  0 siblings, 0 replies; 16+ messages in thread
From: Alan McKinnon @ 2015-06-08  6:25 UTC (permalink / raw
  To: gentoo-user

On 08/06/2015 08:05, Raffaele BELARDI wrote:
> Volker Armin Hemmann wrote:
>> Am 06.06.2015 um 18:45 schrieb Joseph:
>>> I've bunch of php files in many directories and I need to file a text
>>> string in them "Check/Money Order"
>>>
>>> I've tried:
>>> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>>> it doesn't work.
>>>
>>> What is a better method of searching files?
>>
>> grep -R 'whateveryourarelookingfor /path/to/directory/tree/
>>
>> seriously, why make everything fucking harder with find, when grep alone
>> can do it for you?
>>
> 
> I'm not the OP but I was not able to make 'grep -R' work properly with 
> file or directory names containing spaces. I fiddled with IFS but in the 
> end I found 'find -print0' was more convenient. Are there better methods 
> with grep and shell alone?
> 
> raffaele
> 

grep deals with spaces in directory and file names just fine.

If you want to specify directory or file names on the command line that
contain spaces, you must quote them. Standard shell technique.

-- 
Alan McKinnon
alan.mckinnon@gmail.com



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [gentoo-user] search files for "text string"
  2015-06-07 13:00 ` Volker Armin Hemmann
  2015-06-07 14:40   ` Alan McKinnon
  2015-06-08  6:05   ` Raffaele BELARDI
@ 2015-06-08  6:43   ` Andrew Lowe
  2 siblings, 0 replies; 16+ messages in thread
From: Andrew Lowe @ 2015-06-08  6:43 UTC (permalink / raw
  To: gentoo-user

On 06/07/2015 09:00 PM, Volker Armin Hemmann wrote:
> Am 06.06.2015 um 18:45 schrieb Joseph:
>> I've bunch of php files in many directories and I need to file a text
>> string in them "Check/Money Order"
>>
>> I've tried:
>> find -type f -print0 | xargs -r0 grep -F 'Check/Money Order'
>> it doesn't work.
>>
>> What is a better method of searching files?
> 
> grep -R 'whateveryourarelookingfor /path/to/directory/tree/
> 
> seriously, why make everything fucking harder with find, when grep alone
> can do it for you?
> 
> 
	Take a breath, there is no need for swearing. It belittles your
argument. It also paints you as an uneducated buffoon - which I'm
assuming you aren't.

	Regards,
		Andrew


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-06-08  6:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-06 16:45 [gentoo-user] search files for "text string" Joseph
2015-06-06 17:09 ` Alexander Kapshuk
2015-06-06 17:46   ` Joseph
2015-06-06 17:49     ` Alexander Kapshuk
2015-06-06 17:11 ` Philip Webb
2015-06-06 23:40   ` Neil Bothwick
2015-06-07 12:59     ` Volker Armin Hemmann
2015-06-07 14:30       ` Neil Bothwick
2015-06-06 21:04 ` Alan McKinnon
2015-06-07  3:36   ` Joseph
2015-06-07  4:02     ` tlze
2015-06-07 13:00 ` Volker Armin Hemmann
2015-06-07 14:40   ` Alan McKinnon
2015-06-08  6:05   ` Raffaele BELARDI
2015-06-08  6:25     ` Alan McKinnon
2015-06-08  6:43   ` Andrew Lowe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox