This is for Linux+Emacs. The script invokes Emacs with today's date in YYYYMMDD.blg format, and when Emacs closes (after you presumably save your new file) prompts you to archive all current entries, and delete all but the most recent 5.
I'm not doing any error checks, so you could potentially lose data if the copy fails and the unlink succeeds.
#!/usr/bin/perl chomp (my $d=`date +%Y%m%d`); $d.='.blg'; system "emacs -nw $d"; print "Update archive? :"; $d=<>; if($d=~/^y/i) { $d=`cp *.blg blgarchive`; chomp (my @d=sort `ls *.blg`); # Delete all but the last 5 entries for(0..$#d-5){$d=unlink $d[$_];print "$d[$_] : $d\n";} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Add/update daily journal (emacs/linux)
by merlyn (Sage) on Sep 08, 2003 at 14:53 UTC |