[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [SLUG] sh scripting help
This one time, at band camp, Paul Robinson said:
> Got a problem writing a shell script in sh. What it's supposed to
>do is look at a base path, get a directory listing and for each directory
>there it needs to concat the base path with the dir name and run a cat *
>|grep "sometext" on each.
You're not re-implementing rgrep, are you? :)
>I can get a directory listing by doing a ls -l |cut -b 47-57 and that gives
>a list of directories but I cannot get either the path concatination
>working or the "do for each" bit working.
instead of the cut -b, look at setting space as your delimiter and
cutting based on field number, or better yet, use awk which treats
contiguous whitespace as a single delimiter.
In any case, I have this feeling you're trying to do what rgrep already
does, so have a look at it before you go any further.
<Jaq> what's wrong with the default? :)
<jdub> It is poopie.
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug