without a lot of typing (i'm real lazy about that).
Normally,
ls -ltA /somedir |head -x
what if you could just type
lht /somedir 5
well, you can - save the following to your /usr/local/bin as lht with exeute perms (written on redhat ES unsure of outcome for others).
open to suggestions, improvements and portability options, but hopefully it will be helpful to someone else.
PS, its not fussy which way round you specify, number of entries 1st or 2nd, if you give no directory, it takes the current, and if you give no number you get 5. neither need be specified.
lht 5
lht /somedir
lht 20 /somedir
lht /somedir/sub-dir/whatever 12
lht
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
Normally,
ls -ltA /somedir |head -x
what if you could just type
lht /somedir 5
well, you can - save the following to your /usr/local/bin as lht with exeute perms (written on redhat ES unsure of outcome for others).
Code:
#!/bin/sh
#clear
if [ "$#" -lt "2" ] ; then
nonums="$(echo $1 | sed 's/[0-9]//g')"
if [ ! -z "$nonums" ] ; then
ls -ltA $1 --color=always|head
else
num=`expr $1 + 1`
if [ $num -eq 1 ] ; then
num=6
fi
ls -ltA --color=always|head -$num
fi
else
nonums="$(echo $1 | sed 's/[0-9]//g')"
if [ ! -z "$nonums" ] ; then
num=`expr $2 + 1`
if [ $num -eq 1 ] ; then
num=6
fi
ls -ltA $1 --color=always|head -$num
else
num=`expr $1 + 1`
if [ $num -eq 1 ] ; then
num=6
fi
ls -ltA $2 --color=always|head -$num
fi
fi
open to suggestions, improvements and portability options, but hopefully it will be helpful to someone else.
PS, its not fussy which way round you specify, number of entries 1st or 2nd, if you give no directory, it takes the current, and if you give no number you get 5. neither need be specified.
lht 5
lht /somedir
lht 20 /somedir
lht /somedir/sub-dir/whatever 12
lht
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.