#!/usr/bin/perl -w # list month's notebook files. # easiest way: read "ls -lR ~/notebook/..." output. use strict; my $home = $ENV{'HOME'} || die "no home directory\n"; my $nb = "$home/notebook"; -d $nb || die "$nb: directory not found\n"; # create the command. my @a = localtime(time); my $mo = sprintf("%2.2d", $a[4] + 1); my $yr = $a[5] + 1900; my $cmd = "/bin/ls -lFR $nb/$yr/${mo}*"; # read results, get rid of crap we don't need like group names, # top-level LOG files, browser history, etc. my $cfh; my $keeplog; open($cfh, "$cmd |") || die "$cmd: $!\n"; while (<$cfh>) { chomp; # blank lines and junk. next if /^total /; if (length($_) == 0) { print "\n"; next; } # directory names. # if we want to skip RCS stuff, do it here. if (m!^/!) { s!$nb!!; $keeplog = 1; $keeplog = 0 if m!/..../....:$!; print "$_\n"; next; } # files inside directories. next if /^d/; # subdirectories are printed later. next if /browser-history/; @a = split; splice(@a, 3, 1); # zap the group. splice(@a, 1, 1); # zap the link count. next if $a[6] eq 'LOG' && $keeplog == 0; # top LOGs done earlier. printf "%s %8s %11d %s %2s %5s %s\n", @a; } close($cfh); exit(0);