Search Here

Shell Script to implement the DOS command 'TYPE' in LINUX environment


if [ $# -eq 0 ]
    then
        echo -e " File name missing.\n"
        exit
    fi
    count=$#
    if [ $count -eq 1 ]
    then       
        fname=$1
        c=`ls -l | grep -c $fname`
        if [ $c -eq 1 ]
        then
            echo -e "\nFile \"$fname\" Found"
            if [ -f $fname ]
            then
                if [ -s $fname ]
                then        
                    echo -e "Content of file \"$fname\"\n"
                    cat $fname
                else
                    echo -e "File is empty\n"
                fi
            else
                echo -e "\nIt is not a Regular File"
            fi
        else
            echo -e "\nFile not found"       
        fi
    else
        echo -e "Too many parameters\n"
    fi

No comments:

Post a Comment