#!/usr/bin/perl $USAGE = ' SYNOPSIS: Cat files, more or less like pr. OPTIONS: -n line numbers -d printdate -b skipblanks -v verbose -todo hostname/date/pwd in header, file time with each file. NOTES: Fixed to make up for lack of more or less on windows. AUTHOR: (C) GPL, Mohsin_Ahmed http://www.cs.albany.edu/~mosh '; while( $_ = $ARGV[0], /^-/ ){ shift; m/^--$/ && last; if( m/^-v(\d*)/ ){ $verbose++; }elsif( m/^-n/ ){ $linenums++; }elsif( m/^-d/ ){ $printdate++; }elsif( m/^-b/ ){ $skipblanks++; }elsif( m/^-\?/ ){ print $USAGE; exit; }else{ die "invalid option '$_', see -? for help\n"; } } @ARGV || die "Need arg, see -? for help\n"; my $today = localtime; FILE: foreach $filename ( @ARGV ){ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($filename); unless( open(F, "<$filename" ) ){ warn "Cannot read '$filename'\n"; next FILE; } $filecount++; print ":" x 20, " [$filecount] $filename ", ":" x 20; print $today if $printdate; print "\n" ; while(){ next if$skipblanks && m/^\s*$/; printf "%-5d|", $. if $linenums; print $_ ; } close F; print "~" x 20, " $filename ", "~" x 20, "\n"; # print "\f" unless $skipblanks; }