Thursday 21 May 2015

Write a shell script that accepts two file names as arguments, checks if the permissions for these files are identical and if the permissions are identical, output common permissions and otherwise output each file name followed by its permissions.VTU MCA UNIX LAB2A

echo "Enter file name"
read f1 f2
if [ -e $f1 -a -e $f2 ]
then
var1=`ls -l $f1 | cut -c 2-10`
var2=`ls -l $f2 | cut -c 2-10`
    if [ $var1 = $var2 ]
    then
         echo "common permision"
       
    else
        echo "not common"
        echo "$f1 : $var1"
        echo "$f2 : $var2"
    fi
else
 echo "pleas enter some valid file names"
fi

No comments:

Post a Comment