check file script

hi,

i have a small file with 4 rows that looks like this:

any_error_today=
any_message_today=
any_other_thing=
any_other _thing=

I want to write a script that checks if after any = there is no data(is empty), then everything is OK.
If after = there is data written, for example "any_error_today= could not load file", then
the script says "not OK", and prints out the row with problem. In this case: "any_error_today= could not load file"

Thank you very much!

Ervin

grep '=..*' inputfile

Hi, thank you for your reply.
I want to write a little script for this purpose.
Better is in perl, but also with awk is ok.

Thank you in advance!

---------- Post updated at 04:40 AM ---------- Previous update was at 04:35 AM ----------

i have done this so far:

#!/usr/bin/perl -w
use strict;
use warnings;

open FIL, '<myfile';
my $line = <FIL>;
close FIL;

if ($line = ){
print "Everything OK";
}else{
print "$line\n";
}

BUT, this line is not ok if ($line = ). how to tell after = is emty?

thnx

grep '=..*' inputfile || echo "Everything OK"

Can you write it in perl please?

Is this homework???

When a simple grep does the job, why use perl?

If you need awk, then the following will work:

awk '!/\=$/{p=1;print} END{if (!p) print "Everything OK"}' inputfile

Don't know perl...

~/$  cat ~/tmp/tmp.dat
any_error_today=
any_message_today=
any_other_thing=
any_other_thing= Out of cheese error ++REDO FROM START++
any_other _thing=

~/$  egrep '=.+$' ~/tmp/tmp.dat
any_other_thing= Out of cheese error ++REDO FROM START++

So something like this

errors=$(egrep '=.+$' ~/tmp/tmp.dat);if [ "X$errors" == "X" ]; then echo "OK";else echo $errors;fi

---------- Post updated at 11:15 AM ---------- Previous update was at 11:12 AM ----------

Or the whole thing in Perl

 perl -ne 'if (/=.+$/){$err++;print }END{print "OK\n" if ! $err}' ~/tmp/tmp.dat
any_other_thing= Out of cheese error ++REDO FROM START++