In bash, I have a directory that holds some file names that start with underscore _ and others that don't.
I want my script to check if a folder has any files that don't start with _. I write
if [[ -f $dir/[!_]* ]]
then echo "There are unmarked files."
else echo "All files marked."
fi
But when I run using a folder with files that do and do not start with _, the if statement has the opposite effect of what I intended. I list the entries in the folder that clearly display files without _, but the output keeps saying, All files marked.
What am I missing?
{} ';'is not the same as{} +- perhaps you could perform an apples for apples test before commenting further - thanks – Zombo Feb 16 '18 at 16:31