Questions

1:What is the difference between the following commands?
if [ -e /usr/local/bin/bash ] ; then /usr/local/bin/bash ; fi
if [ -x /usr/local/bin/bash ] ; then /usr/local/bin/bash ; fi
2:Given the following variable declarations,
HOME=/home/ranga
BINDIR=/home/ranga/bin

what is the output of the following if statement?

if [ $HOME/bin = $BINDIR ] ; then
    echo "Your binaries are stored in your home directory."
fi
3:Write a test command that can be used to test if /usr/bin is a directory or a symbolic link.
4:Given the following if statement, write an equivalent case statement:
if [ "$ANS" = "Yes" -o "$ANS" = "yes" -o "$ANS" = "y" -o "$ANS" = "Y" ] ;
then
    ANS="y"
else
    ANS="n"
fi

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.