PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > find problem !!
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

find problem !!

Réponse
 
LinkBack Outils de la discussion
Vieux 27/10/2007, 19h21   #1
onkar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut find problem !!

I want to search for a string containing "open" "DBTYPE" "u_int32_t"
"mode" ; How do I do it using find command ??

Thanks,
Onkar

  Réponse avec citation
Vieux 27/10/2007, 22h34   #2
Andrew Smallshaw
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

On 2007-10-27, onkar <onkar.n.m@gmail.com> wrote:
> I want to search for a string containing "open" "DBTYPE" "u_int32_t"
> "mode" ; How do I do it using find command ??


Your intentions are not completely clear, but assuming your want
to search for files containing these strings in turn use something
along the lines of:

find . | xargs fgrep "open"

--
Andrew Smallshaw
andrews@sdf.lonestar.org
  Réponse avec citation
Vieux 28/10/2007, 00h56   #3
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

2007-10-27, 11:21(-07), onkar:
> I want to search for a string containing "open" "DBTYPE" "u_int32_t"
> "mode" ; How do I do it using find command ??

[...]

find . -type f -exec awk '
/open/ && /DBTYPE/ && /u_int32_t/ && /mode/ {
print FILENAME ": " $0
}' {} +

(if I understand the question correctly).

--
Stéphane
  Réponse avec citation
Vieux 29/10/2007, 12h21   #4
Yogesh Sawant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

On Oct 28, 4:56 am, Stephane CHAZELAS <this.addr...@is.invalid> wrote:
> 2007-10-27, 11:21(-07), onkar:> I want to search for a string containing "open" "DBTYPE" "u_int32_t"
> > "mode" ; How do I do it using find command ??

>
> [...]
>
> find . -type f -exec awk '
> /open/ && /DBTYPE/ && /u_int32_t/ && /mode/ {
> print FILENAME ": " $0
> }' {} +
>
> (if I understand the question correctly).
>
> --
> Stéphane


find . -type f | xargs egrep "open|DBTYPE|u_int32_t|mode"
This will list all lines containing any of the four words

If you want to list lines that contain all the four words, then
find . -type f | xargs awk '/open/ && /DBTYPE/ && /u_int32_f/ && /
mode/'

cheers
yogesh

  Réponse avec citation
Vieux 29/10/2007, 13h24   #5
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

2007-10-29, 04:21(-07), Yogesh Sawant:
> On Oct 28, 4:56 am, Stephane CHAZELAS <this.addr...@is.invalid> wrote:
>> 2007-10-27, 11:21(-07), onkar:> I want to search for a string containing "open" "DBTYPE" "u_int32_t"
>> > "mode" ; How do I do it using find command ??

>>
>> [...]
>>
>> find . -type f -exec awk '
>> /open/ && /DBTYPE/ && /u_int32_t/ && /mode/ {
>> print FILENAME ": " $0
>> }' {} +
>>
>> (if I understand the question correctly).
>>
>> --
>> Stéphane

>
> find . -type f | xargs egrep "open|DBTYPE|u_int32_t|mode"
> This will list all lines containing any of the four words
>
> If you want to list lines that contain all the four words, then
> find . -type f | xargs awk '/open/ && /DBTYPE/ && /u_int32_f/ && /
> mode/'

[...]

You can't use xargs in combination with find -print as xargs
expects a very specific input format, not a newline terminated
list of filenames.

And as nothing prevents a filename from containing a newline
character, generally, find -print output is not post-processable
(unless you use some trick like find .//. in order to be able to
know on which line a new file path starts).

Anyway, you don't need to pipe the output of find to xargs,
because find has the -exec {} + predicate that fits that very
purpose.

Also, your second example doesn't print the filename and the
first one may not print it if egrep ends up being given only one
file path.

--
Stéphane
  Réponse avec citation
Vieux 30/10/2007, 05h23   #6
Carl Lowenstein
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

In article <slrnfibkda.74o.stephane.chazelas@spam.is.invalid> ,
Stephane CHAZELAS <this.address@is.invalid> wrote:
>2007-10-29, 04:21(-07), Yogesh Sawant:
>> On Oct 28, 4:56 am, Stephane CHAZELAS <this.addr...@is.invalid> wrote:
>>> 2007-10-27, 11:21(-07), onkar:> I want to search for a string

>containing "open" "DBTYPE" "u_int32_t"
>>> > "mode" ; How do I do it using find command ??
>>>
>>> [...]
>>>
>>> find . -type f -exec awk '
>>> /open/ && /DBTYPE/ && /u_int32_t/ && /mode/ {
>>> print FILENAME ": " $0
>>> }' {} +
>>>
>>> (if I understand the question correctly).
>>>
>>> --
>>> Stéphane

>>
>> find . -type f | xargs egrep "open|DBTYPE|u_int32_t|mode"
>> This will list all lines containing any of the four words
>>
>> If you want to list lines that contain all the four words, then
>> find . -type f | xargs awk '/open/ && /DBTYPE/ && /u_int32_f/ && /
>> mode/'

>[...]
>
>You can't use xargs in combination with find -print as xargs
>expects a very specific input format, not a newline terminated
>list of filenames.


I think I have been using xargs in combination with "find -print" since
late Sixth Edition or early Seventh Edition Unix, when Henry Spenser
reverse-engineered xargs from an AT&T manual page.

Current GNU xargs man.page says
xargs reads items from the standard input, delimited by blanks
(which can be protected with double or single quotes or a
backslash) or newlines, and executes the command (default is
/bin/echo) one or more times with any initial-arguments followed
by items read from standard input. Blank lines on the standard
input are ignored.

Notice the specification "items ... delimited by blanks ... or newlines"

carl
--
carl lowenstein marine physical lab, u.c. san diego
clowenstein@ucsd.edu
  Réponse avec citation
Vieux 30/10/2007, 09h10   #7
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

2007-10-30, 04:23(+00), Carl Lowenstein:
[...]
> I think I have been using xargs in combination with "find -print" since
> late Sixth Edition or early Seventh Edition Unix, when Henry Spenser
> reverse-engineered xargs from an AT&T manual page.


Then, you've never come accross file names containing ', ", \, space,
tab, newline characters, or being too long.

Those characters are as valid in a filename as any, even if not
as common.

I've seen system cron scripts run by root for cleaning /var/tmp
using find+xargs.

Basically, if one does:

mkdir -p '/var/tmp/ /etc'
touch -t <old-date> '/var/tmp/ /etc/passwd'

That script would have deleted /etc/passwd

> Current GNU xargs man.page says
> xargs reads items from the standard input, delimited by blanks
> (which can be protected with double or single quotes or a
> backslash) or newlines, and executes the command (default is
> /bin/echo) one or more times with any initial-arguments followed
> by items read from standard input. Blank lines on the standard
> input are ignored.
>
> Notice the specification "items ... delimited by blanks ... or newlines"


So?

--
Stéphane
  Réponse avec citation
Vieux 30/10/2007, 10h52   #8
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find problem !!

Stephane CHAZELAS <this.address@is.invalid> writes:

> 2007-10-30, 04:23(+00), Carl Lowenstein:
> [...]
> > I think I have been using xargs in combination with "find -print" since
> > late Sixth Edition or early Seventh Edition Unix, when Henry Spenser
> > reverse-engineered xargs from an AT&T manual page.

>
> Then, you've never come accross file names containing ', ", \, space,
> tab, newline characters, or being too long.


That's possible. It all depends if one had control over the creation
of filenames. Personal workstations are one thing. Multi-user
systems/servers, with untrusted users is an entirely different story.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 08h04.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13262 seconds with 16 queries