Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6
Added the perms script
This script takes a certain set of filenames as input and displays their permission in octal format if they exist.
OUTPUT
Commands used
ls -a
bash perms <filename1> <filename2> <filename3>......
Command used
bash perms
Explanation of the code
for file in "$@"; do
Checks for all the files given in arguments
if [ -e "$file" ]; then
Checks for existence of the file in the present working directory
permissions=$(stat -c "%a" "$file")
Retrieves the permissions of a file and assigns them to the variable permissions.
echo "Permissions of '$file' in octal format: $permissions"
Displays the permissions of the file in octal format
echo "File '$file' does not exist."
If the file is not present in the present working directory then displays that Fille does not exist
list_permissions "$@"
Calls the list_permission function
Explanation of the Output
If the script displays the permissions as 775 that means
The first digit (7) represents the permissions for the owner. In octal, 7 means read (4) + write (2) + execute (1), which means the owner has read, write, and execute permissions.
The second digit (7) represents the permissions for the group. Again, 7 means read (4) + write (2) + execute (1), which means the group has read, write, and execute permissions.
The third digit (5) represents the permissions for others. 5 means read (4) + execute (1), which means others have read and execute permissions but not write permissions.