I want to find all *.sh files in some directory, but there are some errors in the script...
#!/bin/sh
for plik in /var/panel/starter/*
do
if [ $(basename "$plik") != "priority" ] && [ $(basename "$plik") != "PRIORITY" ]
then
for plik in $plik/*
do
filename=$(basename "$plik")
extension="${filename##*.}"
filename="${filename%.*}"
if [ "$extension" == "sh" ]
then
echo $plik
fi
done
fi
done
There are some folders in /var/panel/starter, and in these folders there are shell scripts that's why I used for loop twice.
This is the error:
[: 19: *: unexpected operator
[: 19: sh: unexpected operator
[: 19: sh: unexpected operator
[: 19: sh: unexpected operator
[: 19: *: unexpected operator
I guess the problem is with empty folders like:
/var/panel/starter/cs16/*
and I don't have an idea how to deal with that.