Home Linux Shell script that displays list of files have all permissions

Shell script that displays list of files have all permissions

by Anup Maurya
11 minutes read

Shell script that displays list of all the files in the current directory to which the user has read, write and execute permissions.

#!/bin/bash

echo "Files with read, write and execute permissions:"
echo "---------------------------------------------"

# List all files in the current directory that have read, write, and execute permissions
ls -l | grep "^-rwx.*"

echo "---------------------------------------------"

This script first prints a header message to indicate what it is doing. Then it uses the ls command to list all files in the current directory in long format. The grep command is then used to filter out only the files that have read, write, and execute permissions (-rwx). Finally, a separator line is printed to indicate the end of the list.

Save the script as a file, for example list-files-permissions.sh, then make it executable using the chmod command:

chmod +x list-files-permissions.sh

Run the script by typing its name in the terminal:

./list-files-permissions.sh

It will display the list of files in the current directory to which the user has read, write and execute permissions.

related posts

Leave a Comment