Skip to content

Commit

Permalink
iiitl#6 write perms script
Browse files Browse the repository at this point in the history
Script giving permission for a file in octal format
  • Loading branch information
M-ayank2005 committed Mar 16, 2024
1 parent 1a929ec commit 32367fd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scripts/perms
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@
# 775 weather
# 664 ../README.md

#!/usr/bin/env bash

# Function to print permissions of a file in octal format
get_octal_permissions() {
if [ -e "$1" ]; then
stat -c "%a" "$1"
else
echo "File '$1' not found"
fi
}

# Iterate through each file provided as arguments
for file in "$@"; do
permissions=$(get_octal_permissions "$file")
if [ -n "$permissions" ]; then
echo "$permissions $file"
fi
done

0 comments on commit 32367fd

Please sign in to comment.