Shell script to check the file and directory availability

SCRIPT:
#!/bin/bash
DIR=/home/sujin/work/
FIL=/home/sujin/work/shell/if.sh

if [[ -d $DIR && ! -L $DIR ]]
then
    echo "directory $DIR available"
else    
    echo "directory $DIR not available"
fi

if [[ -f $FIL && ! -L $FIL ]]
then
    echo "file $FIL available"
else
    echo "file $FIL not available"
fi


OUTPUT:
run -> ./dir_file_avail.sh
directory /home/sujin/work/ available
file /home/sujin/work/shell/if.sh available


No comments:

Post a Comment