I need to write a script that would take in a path to the folder and list all the subdirectories of that folder.
However, it should not list folders named private.
So far I have come up with this code
if [ -z "$1" ] ; then echo "Nothing entered"
if [ -d "$1" ]; then echo "Directory exists"
else echo "No such directory"
find $1/* -type d ! -name private
The problem is that it does not find the subdirectories for the folder I entered, instead it finds all the subfolders in the system. Is there any way to fix this?
The another issue is that at the moment it works only if i enter the full path to the folder. I would prefer it it worked with relative paths also.
I would appreciate your help.