find problem !!
am 27.10.2007 20:21:57 von onkarI want to search for a string containing "open" "DBTYPE" "u_int32_t"
"mode" ; How do I do it using find command ??
Thanks,
Onkar
I want to search for a string containing "open" "DBTYPE" "u_int32_t"
"mode" ; How do I do it using find command ??
Thanks,
Onkar
On 2007-10-27, onkar
> 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
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
On Oct 28, 4:56 am, Stephane CHAZELAS
> 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=E9phane
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
2007-10-29, 04:21(-07), Yogesh Sawant:
> On Oct 28, 4:56 am, Stephane CHAZELAS
>> 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
In article
Stephane CHAZELAS
>2007-10-29, 04:21(-07), Yogesh Sawant:
>> On Oct 28, 4:56 am, Stephane CHAZELAS
>>> 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
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
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
Stephane CHAZELAS
> 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.