Re: question about a simple 'for `ls`' script



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
.



Relevant Pages

  • Re: Detecting Local Admin for Win32
    ... Google. ... No need to reinvent the wheel if someone has already done the work. ... I'm pasting the original code here instead of giving you my script. ...
    (comp.lang.perl.misc)
  • Re: Formatting variable initializations
    ... > I'm not looking to reinvent the wheel here. ... > anything w/ google. ... Prev by Date: ...
    (comp.emacs)
  • Re: Bareword errors?
    ... reinvent the wheel when the wheel is right infront of you ready to be ... You claim you want full control over how the form data is processed yet ...
    (comp.lang.perl.misc)
  • Re: Somerset and Dorset tears
    ... turn ourselves around in circles to reinvent the wheel. ... We have had the Commission on Integrated Transport ...
    (uk.railway)
  • Re: Embedded OSD (Not STV5370A)
    ... >>would not reinvent the wheel, unless it is a project to learn about. ... been messing with video and image processing for too many years. ...
    (comp.arch.embedded)