Reputation: 282
I'm writing a script for BusyBox ash, and need to determine if a subdirectory exists so my script can display an error message.
Normally if test -d sub/directory
would be my go-to, but the problem here is there's one folder I don't want to trip this logic.
I currently use ls /folder/*/bar | grep -v foo
and parse the exit code but I know that's bad practice.
Here's what I'm looking at (bar should trip the logic, foo should not)
/folder/foo/bar <- this should not trip because it contains foo
/folder/dev/bar <- should trip because it contains bar but not foo
/folder/randome/name <- should not trip doesn't contain bar
Is there a proper/better way to do this?
Upvotes: 0
Views: 327