All pastes #964319 Raw Edit

head in unix

public text v1 · immutable
#964319 ·published 2008-03-31 03:41 UTC
rendered paste body
if [ $# -gt 2 ]
then
        echo Too Many Arguements
elif [ $# -eq 0 ]
then
        echo No Arguments
elif [ $# -eq 1 ]
then
        if [ -f $1 ]
        then
                exec < $1
                i=10
                if [ -f t1 ]
                then
                        rm t1
                fi
                while [ $i -gt 0 ]
                do 
                        read l
                        echo $l|cat >> t1
                        i=`expr $i - 1`
                done
                cat t1
        else
                echo File does not exists
        fi
else
        if [ -f $2 ]
        then
                exec < $2
                i=$1
                if [ -f t1 ]
                then
                        rm t1
                fi
                while [ $i -gt 0 ]
                do
                        read l
                        echo $l|cat >> t1
                        i=`expr $i - 1`
                done
                cat t1
        else
                echo File does not exists
        fi
fi