Sunday, August 27, 2017

Shell script to check the file and directory availability

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



download file now

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.