[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A few questions



On Apr 23, Christian Leutloff wrote
: kc5vxy@juno.com (Kevin J Poorman) writes:
: 
: > 1: I have a text file that in of itself is a list of files. I would like
: > to take that list and grep though them to find a string. I think this can
: > be done with a shell script (Bash) but I have know idea how. Can anyone
: > give me some pointers and or post a script ? ... TIA
: 
: use the command grep when ou want to grep ;-)
: 
: man grep 
: will you tell more about it.

Do you want to grep in the file containing the list?  Or do you want to
grep in the files, contained in the list?  The first --> man grep.
The latter --> man grep xargs

	cat filelist | xargs grep pattern /dev/null
or
	xargs grep pattern /dev/null <filelist

The /dev/null ensures, that there is at least one arg to grep into, so
in case, xargs outputs a single arg to grep, you get the same output
from grep (file_name: matching line) as for the other cases.  (e.g.,
try:

	grep include /usr/include/stdio.h
vs.
	grep include /dev/null /usr/include/stdio.h

:  
: > 2: The purpose of the above question is to find a file that has a string
: > (IE search all the files on the hard drive for the string "foo" and list
: > the files that have foo in it) 

	find / -type f | xargs grep -l /dev/null

... and go for a cup of tea ;-)


: > Now that I know what file has "foo" in it
: > I need to log all the programs that write to this file ?
: > eg. program foobar and program foobarx both write to text file
: > /usr/lib/cows I need to know what program is writing to that file and
: > when

Not easy ... probably impossible.
Some attempts could be done, if you'd try to find any files, having
the file name foo in its binary.  But this is done above  ;-)

Probably you could try the ``logwrites'' package.



    Heiko
--
email : heiko@lotte.sax.de heiko@debian.org heiko@sax.de
pgp   : A1 7D F6 7B 69 73 48 35  E1 DE 21 A7 A8 9A 77 92 
finger: heiko@sax.sax.de         heiko@master.debian.org

Attachment: pgpC33lFOFRsq.pgp
Description: PGP signature


Reply to: