Search Here

Shell Script to reverse all words of a given line. The line is supplied as command line argument


clear
if [ $# -eq 0 ]
then
    echo -e "ERROR: At least one argument is required"
else
    echo -e "\nLine before reversal"
    echo -e "===================="
    echo -e "$*\c"
   
    echo -e "\n\nLine after reversal"
    echo -e "===================="
    for i in $*
    do
        tmp=`echo $i | rev`
        echo -e "$tmp \c"
    done
    echo
fi 

No comments:

Post a Comment