Path Count
In this challenge, you are required to create a script that displays the number of executable files in each directory listed in the $PATH
environmental variable.
Tasks
You need to complete the following tasks:
- Fetch each directory from the
PATH
variable.
- Use the
-x
option in the if
condition to check executable permission.
- Print the directory and the number of executable files one by one.
- Print the total number of executable files at the end.
- Count only files with executable permission.
- Verify the presence of the path every time.
Requirements
You must meet the following requirements:
- The script should be named
pathCount.sh
.
- The working directory for the script should be
~/project
.
- Utilize Bash environmental variables.
- Understand the working of the
tr
command.
- Use loops and arrays.
- Check the permission of files in the script.
Example
current directory: /usr/lib/jvm/java-11-openjdk-amd64/bin
current count: 34
current directory: /usr/lib/jvm/java-11-openjdk-amd64/bin
current count: 34
current directory: /usr/lib/code-server/lib/vscode/bin/remote-cli
current count: 2
...
[OUTPUT] Total-Count: [2135] [OUTPUT]