-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2a.sh
More file actions
29 lines (28 loc) · 707 Bytes
/
2a.sh
File metadata and controls
29 lines (28 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Write a shell script that accepts two filenames as arguments, checks if the permissions for these files are identical and if the permissions are identical, output common permissions otherwise output each filename followed by its permissions.
echo "Enter the first file"
read file1
if [ -e $file1 ]
then
set -- `ls -l $file1`
file1perm=$1
else
echo "$file1 doesnot exist"
exit
fi
echo "Enter the second file"
read file2
if [ -e $file2 ]
then
set -- `ls -l $file2`
file2perm=$1
else
echo "$file2 doesnot exist"
exit
fi
if [ $file1perm = $file2perm ]
then
echo "Permissions are identical and permissoins are '$file1perm'"
else
echo "$file1 permission is $file1perm"
echo "$file2 permission is $file2perm"
fi