Tech Support > Operating Systems > Linux / Variants > members & files containg text
members & files containg text
Posted by Jhuola Hoptire on January 23rd, 2004



members doesn't work in Fedora.
Is there another way to find users in a group?

How do I list all files with a particular
bit of text in them?

Posted by Chris F.A. Johnson on January 23rd, 2004


On Fri, 23 Jan 2004 at 23:45 GMT, Jhuola Hoptire wrote:
Nor does it on any of the systems I use (MDK-Linux, FreeBSD,
SunOS).

grep $group /etc/group

text=bit_of_text
FILE_LIST=*
grep -l "$text" $FILE_LIST

--
Chris F.A. Johnson http://cfaj.freeshell.org
================================================== =================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License

Posted by Dave Millen on January 23rd, 2004


On Fri, 23 Jan 2004 23:45:01 +0000, Jhuola Hoptire wrote:

grep <groupname>:x /etc/group

Put the following into a script called findtext or similar in ~/bin:

#! /bin/sh

grep -rl "$1" * | grep -v "is a directory"

Then cd to the top of the tree you want to search and call the script with:

findtext "text to find"

Regards,
Dave


Posted by Jhuola Hoptire on January 24th, 2004


Chris F.A. Johnson wrote:


I open a couple of terminals (working remotely).
I run top in one.
Then I run the script looking at all files
starting from / (a bit drastic, but a good test).
grep first grabs a load of cpu, but quickly
drops down to 0% and, grep never returns (I don't
get the prompt back). When I choose a more sensible starting
directory, it works fine.
Could it be runnig out of memory, or ...? Any
ideas?


Posted by Chris F.A. Johnson on January 24th, 2004


On Sat, 24 Jan 2004 at 01:06 GMT, Jhuola Hoptire wrote:
I've noticed that grep sometimes hangs when used recursively; it
may be a bug. It hasn't happened often enough that I've felt moved
to investigate.

--
Chris F.A. Johnson http://cfaj.freeshell.org
================================================== =================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License

Posted by Jhuola Hoptire on January 24th, 2004


I have found evidence of others encountering
a similar problem. It seems to be related to
how grep treats *. It expands it to be teh
contents of a directory., and uses this as
its parameter. But if a directory is empty,
there are not enough parameters, so grpe waits
for input at stdin.
I hope that makes sense.

Chris F.A. Johnson wrote:

Posted by Jim Richardson on January 24th, 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 24 Jan 2004 01:06:27 GMT,
Jhuola Hoptire <JH@nothere.com> wrote:
greping through the whole /proc and other "misc filesystems" might
produce results you didn't expect.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAEdtwd90bcYOAWPYRAuUjAJ0XyM4+m1Je3pUcC7/+kJeU2hIPQwCgl+z1
jVfuKn6BbWnRgPYBtFmtYVQ=
=lHYY
-----END PGP SIGNATURE-----

--
Jim Richardson http://www.eskimo.com/~warlock
A positive attitude may not solve all your problems,
but it will annoy enough people to make it worth the effort.

Posted by Jeroen Geilman on January 27th, 2004


Jim Richardson wrote:

The clearest of which is connecting /proc/kcore in any way with a console...

The only result from that is : bye bye!

Log in from somewhere else and kill the process, because it'll never return.

But then, you probably knew that ;-)

--
Jeroen Geilman

Analog bits courtesy of adaptr.