If/Testing the existence of certain numerous files [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
This question already has an answer here:
Test if there are files matching a pattern in order to execute a script
8 answers
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?
files regular-expression directory
marked as duplicate by don_crissti, Timothy Martin, Kusalananda, Jeff Schaller, muru Feb 16 at 2:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
This question already has an answer here:
Test if there are files matching a pattern in order to execute a script
8 answers
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?
files regular-expression directory
marked as duplicate by don_crissti, Timothy Martin, Kusalananda, Jeff Schaller, muru Feb 16 at 2:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Test if there are files matching a pattern in order to execute a script
8 answers
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?
files regular-expression directory
This question already has an answer here:
Test if there are files matching a pattern in order to execute a script
8 answers
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?
This question already has an answer here:
Test if there are files matching a pattern in order to execute a script
8 answers
files regular-expression directory
asked Feb 15 at 19:27
Jason
174
174
marked as duplicate by don_crissti, Timothy Martin, Kusalananda, Jeff Schaller, muru Feb 16 at 2:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by don_crissti, Timothy Martin, Kusalananda, Jeff Schaller, muru Feb 16 at 2:06
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
if find -not -name '_*' -exec false +
then
echo 'all files marked'
else
echo 'unmarked file found'
fi
@muru';'
is not the same as+
- perhaps you could perform an apples for apples test before commenting further - thanks
â Steven Penny
Feb 16 at 16:31
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
if find -not -name '_*' -exec false +
then
echo 'all files marked'
else
echo 'unmarked file found'
fi
@muru';'
is not the same as+
- perhaps you could perform an apples for apples test before commenting further - thanks
â Steven Penny
Feb 16 at 16:31
add a comment |Â
up vote
0
down vote
if find -not -name '_*' -exec false +
then
echo 'all files marked'
else
echo 'unmarked file found'
fi
@muru';'
is not the same as+
- perhaps you could perform an apples for apples test before commenting further - thanks
â Steven Penny
Feb 16 at 16:31
add a comment |Â
up vote
0
down vote
up vote
0
down vote
if find -not -name '_*' -exec false +
then
echo 'all files marked'
else
echo 'unmarked file found'
fi
if find -not -name '_*' -exec false +
then
echo 'all files marked'
else
echo 'unmarked file found'
fi
answered Feb 16 at 0:24
Steven Penny
2,29021635
2,29021635
@muru';'
is not the same as+
- perhaps you could perform an apples for apples test before commenting further - thanks
â Steven Penny
Feb 16 at 16:31
add a comment |Â
@muru';'
is not the same as+
- perhaps you could perform an apples for apples test before commenting further - thanks
â Steven Penny
Feb 16 at 16:31
@muru
';'
is not the same as +
- perhaps you could perform an apples for apples test before commenting further - thanksâ Steven Penny
Feb 16 at 16:31
@muru
';'
is not the same as +
- perhaps you could perform an apples for apples test before commenting further - thanksâ Steven Penny
Feb 16 at 16:31
add a comment |Â