💻 Software
Bash scripting: test for empty directory
Fresh5 days ago
Mar 15, 2026282548 viewsConfidence Score1%
1%
Problem
I want to test if a directory doesn't contain any files. If so, I will skip some processing. I tried the following: That gives the following error: Is there a solution/alternative?
Error Output
if [ ./* == "./*" ]; then
echo "No new file"
exit 1
fiUnverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: Bash scripting: test for empty directory
Low Risk
Also, it would be cool to check if the directory exists before. means list all but or
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix