Hi,
I have a server which appends to two different backup logs, a summary and a full log,
I want to write a script which will email out this mornings backup,
the problem is that in the log files the date is in the below format:
Fri May 31,2013 02:30
the summary log file I can just use Head to get the data, but in the full log because the log is a different length each day is proving difficult,
In the full summary each days log is delimited by
See he man page of the "date" command, it shouldn't be so complicated to get the date in this format to compare it to the log contents.
Then it is easy: use "sed"s range capability to print/delete only the lines in certain range:
mydate="$(date +'<appropriate format string here>')"
sed -n '/'"$mydate"'/,/^\*\{25\}/ p' /path/to/logfile
The sed-invocation will only print the lines starting with the first line containing your date to a line starting with 25 asterisks (i haven't bothered to count your line, correct the number if necessary). If you want to delete the files from the log use the same method but use "d" instead of "p" as a command.
Ok here is a stupid question but i can never remember how to do it,
the script is working fine but for some reason it is duplicating some of the lines
How do you remove duplicate lines?
---------- Post updated at 03:53 PM ---------- Previous update was at 12:58 PM ----------
This is really strange,
I tried running the script and I dont get any response,
just goes back to the prompt,
This made me think there are no entries in the log file for today,
but if i run the date command by its self it displays the date the way it should