| thuang2@hotmail.com 2006-05-09, 9:56 pm |
| Hi,
My shell script (bash) does some queries every hour and append result
of the query to a log file. If there is no result, the query would
return something like "Query has no entries." If the previous hour's
query result is also "Query has no entries," then instead of appending
the result, the script only modifies the timestamp for the last "Query
has no entries" section in the log file.
The log file looks like this:
############
Query time - May 8 07:59:14 PDT 2006
Query has no entries
############
Query time - May 8 08:59:14 PDT 2006
[Some content here]
....
############
Query time - May 8 09:59:14 PDT 2006
Query has no entries
In this case, the script needs to check whether the last entry in the
log file is "Query has no entries" and if it is, the script needs to
modify the timestamp (i.e. "May 8 09:59:14 PDT 2006") in the last
"Query has no entries" section? Is there any way to do that using awk
or sed? Thanks.
|