created shell dir

This commit is contained in:
2025-02-23 15:43:13 +00:00
parent b1f506bbd9
commit 4372a9042b
14 changed files with 0 additions and 0 deletions

49
shell/filetest.sh Normal file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
#for provided file print the summary of what permissions users has granted
#example: ./filetest.sh hello.txt
#READ: YES
#WRITE: NO
#EXECUTABLE:NO
#argument check
if [ $# -ne 1 ]; then
echo "Provide exactly one argument"
exit 1
fi
#variable assignment
FILE=$1
#check if the file exists
if [ -f $FILE ]; then
#default variables
VAR_READ="NO"
VAR_WRITE="NO"
VAR_EXEC="NO"
#check if file is readable
if [ -r $FILE ]; then
VAR_READ="YES"
fi
#check if file is writable
if [ -w $FILE ]; then
VAR_WRITE="YES"
fi
#check if file is executable
if [ -x $FILE ]; then
VAR_EXEC="YES"
fi
#write permissions summary to user
echo "==FILE: $FILE=="
echo "READ: $VAR_READ"
echo "WRITE: $VAR_WRITE"
echo "EXECUTABLE: $VAR_EXEC"
else
echo $FILE does not exists
fi