This is a small script to check if two given files permissions are same or not


#!/bin/bash
#Purpose: To check two given files are having same permissions or not
#Author: Surendra Anne(surendra@linuxnix.com)
#Date:2012-04-24
#Modified:::


read -p “Enter two files with their paths” FILE1 FILE2


PERM1=$(stat –printf=”%a” $FILE1)
PERM2=$(stat –printf=”%a” $FILE2)


if [ $PERM1 -eq $PERM2 ]
then
echo “Both the files have same permissions: $PERM1”
else
echo “The given files have different permissions”
fi


Some of the tools used here are
read command
Command substitution
stat command
square brackets
if statement
The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.