I wanted to write a script on my Ubuntu to show all the executable files in all of the directories in the $PATH
variable. Here is my script:
#!/bin/bash
IFS=:
for dir in $PATH;do
echo $dir:
for files in $dir/*;do
b=$(basename $files)
[ -x "$b" ] && echo $" $b"
done
done
but the output is
/usr/local/sbin:
/usr/local/bin:
/usr/sbin:
/usr/bin:
/sbin:
/bin:
/usr/games:
/usr/local/games:
/snap/bin:
/home/sudin/programming/shell:
brightness
for
ifthen
loop
mat2
myfind
searchex
Why aren't the executable files of other directories listed?