Re: question about a simple 'for `ls`' script
- From: j.goerke@xxxxxxxxxxx
- Date: Wed, 8 Nov 2006 16:03:43 +0000 (UTC)
jcc <jccpro@xxxxxxxxx> wrote:
I have been away from university for 6 years. I don't know much about
Unix. Maybe my question is too stupid, or you guys think I can google
the answer easily. But I haven't found the answer.
It's just that your questions are a lot like the homework assignments
we give to our apprentices.
Maybe you don't
think the 'for `ls`' has any value for a commercial project. I can
understand that. I just simplified the problem.
Usually "for i in *" is a bit smaller and faster than "for i in `ls`".
What I wrote is a small
utility to grep files recrusively. Again, maybe I just tried to
reinvent the wheel.
You are trying to reinvent the wheel. GNU grep does recursion, but
even if you're restricted to vendor-supplied utilities you can always
find at least two different ways to solve your problem:
#!/bin/sh
if [ $# -eq 1 ]
then
find . -type f -exec grep -l $1 {} \;
else
echo "usage: `basename $0` \"keyword\""
exit 1
fi
When learning about UN*X and derivates I used to go through man-pages,
following every "See also". That way I could find the correct utility
and/or option when the need arose later.
Jens
--
Jens Goerke, mobilcom Server Systeme
mobilcom Communicationstechnik GmbH, Hollerstr. 126, 24782 Buedelsdorf
Tel: +49-(0)4331-69-5505 Fax: +49-(0)4331-69-5599
.
- Follow-Ups:
- References:
- question about a simple 'for `ls`' script
- From: jcc
- Re: question about a simple 'for `ls`' script
- From: j . goerke
- Re: question about a simple 'for `ls`' script
- From: jcc
- question about a simple 'for `ls`' script
- Prev by Date: Re: question about a simple 'for `ls`' script
- Next by Date: Re: question about a simple 'for `ls`' script
- Previous by thread: Re: question about a simple 'for `ls`' script
- Next by thread: Re: question about a simple 'for `ls`' script
- Index(es):
Relevant Pages
|