#!/bin/bash # # 'lt2' - "ls -alt" with limited number of lines. # # Rev 00 04/30/02 From 'lt'. # Rev 01 11/24/03 Better handling of names with embedded spaces. # ################################################################## # max number of lines LIMIT=10 DIR=no if [ $# -eq 1 ] ; then if [ -d $1 ] ; then cd $1 DIR=yes COUNT=`ls -alF |wc -l` fi elif [ $# -eq 0 ] ; then DIR=yes COUNT=`ls -alFt |wc -l` else COUNT=`ls -adlFt "$@" |wc -l` fi # the following in case non-existant filename entered if [ X"$COUNT" = X ] ; then COUNT=1 fi SKIPPED=$(($COUNT - $LIMIT)) if [ $DIR = yes ] ; then if let $(($COUNT > $LIMIT)) ; then ls -alFt |head -n $LIMIT echo "... [$SKIPPED older items not printed]" else ls -alFt fi else if let $(($COUNT > $LIMIT)) ; then ls -adlFt "$@" |head -n $LIMIT echo "... [$SKIPPED older items not printed]" else ls -adlFt "$@" fi fi exit 0