if [ $# -ne 2 ]
then
echo " invalid argument "
exit
fi
if [ ! -e $1 ]
then
echo "invalid file name "
exit
fi
echo " 1. head "
echo " 2. tail "
read ch
case "$ch" in
1)exec < $1
i=1
while [ $i -le $2 ]
do
read l
echo $l
i=`expr $i + 1`
done ;;
2)exec < $1
i=1
while read l
do
i=`expr $i + 1`
done
j=`expr $i - $2`
k=1
exec < $1
while [ $k -lt $j ]
do
read l
k=`expr $k + 1`
done
while read l
do
echo $l
done ;;
*) echo "invalid choice" ;;
esac