Check file permissions | UNIX shell script

Problem
Write a UNIX shell script that accepts exactly two file names as arguments, checks if both the files have
the same permissions. If both files have same permissions then print that permission of any one of the file. If the permissions of each file are different, then display the permission of both the files separately.

#! /bin/bash
# Created by Zain Aftab

if [ $# -ne 2 ]
then
        echo "plz enter only to command line arguments"
        exit 0
else
f1=$1
f2=$2

set [`ls -l $f1`]
f1=$1

set [`ls -l $f2`]
f2=$1

if [ $f1 = $f2 ]
then
echo "The permissions of files are same which are following"
echo $f1
else

echo "The different permissions"
    echo "first file permissions"
echo $f1
echo "second file permissions"
       echo $f2
fi
fi

Comments

Popular posts from this blog

Assembly Program Code For Brick Breaker Game

The Untold Story: U.S. Special Forces' Bold Pursuit of Adolf Hitler