I'm currently working on a homework assignment and I need to take a given directory path and from that list the files and directories in it. While also including if it's executable or not. I'm also restricted by not being allowed to use any other languages except bash.
My original thought was to use ll and cut to get what I needed but I couldn't seem to get it to work. Then I was thinking I could use something like (not working, just an idea)
read input
for f in $input
do
if [[ -x "$f" ]]
then
echo "$f is executable"
else
echo "$f is not executable"
fi
done
I need the output to be something like and I'm not sure how to get there
file-name1 is executable
file-name2 is not executable
directory1 is executable
[[ -x filename ]]is a perfectly legitimate construct in bash. Would you be using some other shell may be ?for f in $input, tryfor f in ${input}/*. Making sure the value of$inputis a readable directory is an exercise I shall leave for you.