1
I am trying to write a script that, at some point, needs to check the user privileges of multiple folders. The paths are stored in a variable, each path in a new line.
So far I have this:
output=$PATH
output=$(echo "$output" | tr ':' '\n' | sort )
arr=($(echo "$output"))
for i in "$arr"
do
echo "$i"
if ! [[ -x $i ]]; then
echo "You are missing execute Permission on
echo "$i"
fi
done
The output contains several paths, in my case the content of my $PATH
variable.
With the first line I try to convert the multi line variable into an array and then iterate over all array elements.
When I run the code it only works for the first entry, the echo "$i"
only displays /bin
before exiting the loop.
So I guess I did not convert the multi line variable to an array.
Ok I edited my initial post – NIoSaT – 2016-10-16T22:02:43.140