Re: writing cron job to print query results

From: Ed Murphy (emurphy42_at_socal.rr.com)
Date: 07/14/03


Date: Mon, 14 Jul 2003 15:40:05 GMT

On Mon, 14 Jul 2003 10:36:26 +0000, Detroit wrote:

> R> user = sample {
> R> default service = permit
> R> login = cleartext "password"
> R> chap = cleartext "password"
> R> service = ppp protocol = ip {
> R> default attribute = permit
> R> }
> R> }
> R>
> R> I want to search for the login line, and if it exists print out the
> R> user = name from above. Is this possible to do with a grep and if
> R> statement in a cron job?

> $ grep -B2 '\<login = ' file | sed -n '{p;n;n;p;n;}'

This prints the login lines as well as the user lines. To print just
the user lines, use this:

$ grep -B2 '\<login = ' file | sed -n '{p;n;n;n;}'