Bash for loop on all files in folder except one [duplicate]
This question already has an answer here:
Exclude one pattern from glob match
3 answers
I have a folder filled with 9 Robot Framework test files. Only 8 of them have to be executed, as the last one is used to set up all the others (let's call it config.robot).
If I had to run all those tests I would have done something like
for test_file in folder/*.robot; do
robot -b debug.log -d log/ $test_file.robot;
done
but in this case it means that config.robot will also be run, which I don't want.
How could I perform a for loop on all files in folder except one?
If that helps, all files except config.robot respect the following naming syntax: they all start with their execution order and are followed by their actual name, e.g. 01__init-connection.robot.
Edit: Before posting that question I had already seen and tried the answers offered in Exclude one pattern from glob match and wrote something similar to
shopt -s extglob
for test_file in folder/!(config).robot; do ...
But Robot Framework does not recognize the file name:
Parsing 'folder/!(config).robot' failed: Data source does not exist.
so I guess that Robot Framework doesn't like that syntax.
I'm thinking about setting a variable with the results of a find according to a regex matching my filename structure and then performing the for loop on the variable:
SUITES=$(find . -regex '^[0-9][0-9][a-zA-Z_-]*')
for SUITE in $SUITES; do robot -b ...
But for some reason when I echo SUITES it returns nothing. I don't know what I missed here.
bash shell-script for
marked as duplicate by don_crissti, elbarna, Kusalananda, Thomas, jimmij Jan 30 at 11:55
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 |
This question already has an answer here:
Exclude one pattern from glob match
3 answers
I have a folder filled with 9 Robot Framework test files. Only 8 of them have to be executed, as the last one is used to set up all the others (let's call it config.robot).
If I had to run all those tests I would have done something like
for test_file in folder/*.robot; do
robot -b debug.log -d log/ $test_file.robot;
done
but in this case it means that config.robot will also be run, which I don't want.
How could I perform a for loop on all files in folder except one?
If that helps, all files except config.robot respect the following naming syntax: they all start with their execution order and are followed by their actual name, e.g. 01__init-connection.robot.
Edit: Before posting that question I had already seen and tried the answers offered in Exclude one pattern from glob match and wrote something similar to
shopt -s extglob
for test_file in folder/!(config).robot; do ...
But Robot Framework does not recognize the file name:
Parsing 'folder/!(config).robot' failed: Data source does not exist.
so I guess that Robot Framework doesn't like that syntax.
I'm thinking about setting a variable with the results of a find according to a regex matching my filename structure and then performing the for loop on the variable:
SUITES=$(find . -regex '^[0-9][0-9][a-zA-Z_-]*')
for SUITE in $SUITES; do robot -b ...
But for some reason when I echo SUITES it returns nothing. I don't know what I missed here.
bash shell-script for
marked as duplicate by don_crissti, elbarna, Kusalananda, Thomas, jimmij Jan 30 at 11:55
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.
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
1
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try whattouch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; donedoes in an empty directory, it should print the names offoo.robotandbar.robot.
– ilkkachu
Jan 29 at 18:21
GNUfindhas its peculiar approach to regular expressions. It supports several regex types, defaulting toemacs. Also, note thatfindregular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in./folder(relative to the current directory), you may usefind . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.
– fra-san
Jan 29 at 18:53
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct forbash.
– Kusalananda
Jan 29 at 19:42
Any other shell than Bash would probably not haveshopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error fromrobot.)
– ilkkachu
Jan 29 at 20:04
add a comment |
This question already has an answer here:
Exclude one pattern from glob match
3 answers
I have a folder filled with 9 Robot Framework test files. Only 8 of them have to be executed, as the last one is used to set up all the others (let's call it config.robot).
If I had to run all those tests I would have done something like
for test_file in folder/*.robot; do
robot -b debug.log -d log/ $test_file.robot;
done
but in this case it means that config.robot will also be run, which I don't want.
How could I perform a for loop on all files in folder except one?
If that helps, all files except config.robot respect the following naming syntax: they all start with their execution order and are followed by their actual name, e.g. 01__init-connection.robot.
Edit: Before posting that question I had already seen and tried the answers offered in Exclude one pattern from glob match and wrote something similar to
shopt -s extglob
for test_file in folder/!(config).robot; do ...
But Robot Framework does not recognize the file name:
Parsing 'folder/!(config).robot' failed: Data source does not exist.
so I guess that Robot Framework doesn't like that syntax.
I'm thinking about setting a variable with the results of a find according to a regex matching my filename structure and then performing the for loop on the variable:
SUITES=$(find . -regex '^[0-9][0-9][a-zA-Z_-]*')
for SUITE in $SUITES; do robot -b ...
But for some reason when I echo SUITES it returns nothing. I don't know what I missed here.
bash shell-script for
This question already has an answer here:
Exclude one pattern from glob match
3 answers
I have a folder filled with 9 Robot Framework test files. Only 8 of them have to be executed, as the last one is used to set up all the others (let's call it config.robot).
If I had to run all those tests I would have done something like
for test_file in folder/*.robot; do
robot -b debug.log -d log/ $test_file.robot;
done
but in this case it means that config.robot will also be run, which I don't want.
How could I perform a for loop on all files in folder except one?
If that helps, all files except config.robot respect the following naming syntax: they all start with their execution order and are followed by their actual name, e.g. 01__init-connection.robot.
Edit: Before posting that question I had already seen and tried the answers offered in Exclude one pattern from glob match and wrote something similar to
shopt -s extglob
for test_file in folder/!(config).robot; do ...
But Robot Framework does not recognize the file name:
Parsing 'folder/!(config).robot' failed: Data source does not exist.
so I guess that Robot Framework doesn't like that syntax.
I'm thinking about setting a variable with the results of a find according to a regex matching my filename structure and then performing the for loop on the variable:
SUITES=$(find . -regex '^[0-9][0-9][a-zA-Z_-]*')
for SUITE in $SUITES; do robot -b ...
But for some reason when I echo SUITES it returns nothing. I don't know what I missed here.
This question already has an answer here:
Exclude one pattern from glob match
3 answers
bash shell-script for
bash shell-script for
edited Jan 30 at 8:51
avazula
asked Jan 29 at 10:31
avazulaavazula
1013
1013
marked as duplicate by don_crissti, elbarna, Kusalananda, Thomas, jimmij Jan 30 at 11:55
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, elbarna, Kusalananda, Thomas, jimmij Jan 30 at 11:55
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.
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
1
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try whattouch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; donedoes in an empty directory, it should print the names offoo.robotandbar.robot.
– ilkkachu
Jan 29 at 18:21
GNUfindhas its peculiar approach to regular expressions. It supports several regex types, defaulting toemacs. Also, note thatfindregular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in./folder(relative to the current directory), you may usefind . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.
– fra-san
Jan 29 at 18:53
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct forbash.
– Kusalananda
Jan 29 at 19:42
Any other shell than Bash would probably not haveshopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error fromrobot.)
– ilkkachu
Jan 29 at 20:04
add a comment |
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
1
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try whattouch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; donedoes in an empty directory, it should print the names offoo.robotandbar.robot.
– ilkkachu
Jan 29 at 18:21
GNUfindhas its peculiar approach to regular expressions. It supports several regex types, defaulting toemacs. Also, note thatfindregular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in./folder(relative to the current directory), you may usefind . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.
– fra-san
Jan 29 at 18:53
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct forbash.
– Kusalananda
Jan 29 at 19:42
Any other shell than Bash would probably not haveshopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error fromrobot.)
– ilkkachu
Jan 29 at 20:04
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
1
1
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try what
touch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; done does in an empty directory, it should print the names of foo.robot and bar.robot.– ilkkachu
Jan 29 at 18:21
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try what
touch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; done does in an empty directory, it should print the names of foo.robot and bar.robot.– ilkkachu
Jan 29 at 18:21
GNU
find has its peculiar approach to regular expressions. It supports several regex types, defaulting to emacs. Also, note that find regular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in ./folder (relative to the current directory), you may use find . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.– fra-san
Jan 29 at 18:53
GNU
find has its peculiar approach to regular expressions. It supports several regex types, defaulting to emacs. Also, note that find regular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in ./folder (relative to the current directory), you may use find . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.– fra-san
Jan 29 at 18:53
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct for
bash.– Kusalananda
Jan 29 at 19:42
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct for
bash.– Kusalananda
Jan 29 at 19:42
Any other shell than Bash would probably not have
shopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error from robot.)– ilkkachu
Jan 29 at 20:04
Any other shell than Bash would probably not have
shopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error from robot.)– ilkkachu
Jan 29 at 20:04
add a comment |
3 Answers
3
active
oldest
votes
In bash, as tagged:
shopt -s extglob
for test_file in folder/!(config).robot; do robot -b debug.log -d log/ "$test_file".robot; done
add a comment |
You can use the continue command.
Also note that the variable picks up the whole path.
for f in folder/*.robot; do
test "$f" = folder/config.robot && continue
robot -b debug.log -d log/ "$f"
done
add a comment |
Try this,
for test_file in folder/*.robot;
do
[ "$test_file" != "config.robot" ] && robot -b debug.log -d log/ $test_file.robot;
done
robotwill run only if$test_fileis not equal toconfig.robot
or simple using find
find folder/*.robot ! -name "config.robot" -exec robot -b debug.log -d log/ {} +
Usingextglob(as in @sparhawk comment) is more efficient...
– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike theifsolution
– ilkkachu
Jan 29 at 18:23
find folder/*.robot ...works but is a bit odd. You'd usually usefind . -name "*.robot" ! -name "config.robot" -exec ...Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...
– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the originalsh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.
– xenoid
Jan 29 at 23:48
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
In bash, as tagged:
shopt -s extglob
for test_file in folder/!(config).robot; do robot -b debug.log -d log/ "$test_file".robot; done
add a comment |
In bash, as tagged:
shopt -s extglob
for test_file in folder/!(config).robot; do robot -b debug.log -d log/ "$test_file".robot; done
add a comment |
In bash, as tagged:
shopt -s extglob
for test_file in folder/!(config).robot; do robot -b debug.log -d log/ "$test_file".robot; done
In bash, as tagged:
shopt -s extglob
for test_file in folder/!(config).robot; do robot -b debug.log -d log/ "$test_file".robot; done
answered Jan 29 at 12:25
Jeff SchallerJeff Schaller
41.1k1056131
41.1k1056131
add a comment |
add a comment |
You can use the continue command.
Also note that the variable picks up the whole path.
for f in folder/*.robot; do
test "$f" = folder/config.robot && continue
robot -b debug.log -d log/ "$f"
done
add a comment |
You can use the continue command.
Also note that the variable picks up the whole path.
for f in folder/*.robot; do
test "$f" = folder/config.robot && continue
robot -b debug.log -d log/ "$f"
done
add a comment |
You can use the continue command.
Also note that the variable picks up the whole path.
for f in folder/*.robot; do
test "$f" = folder/config.robot && continue
robot -b debug.log -d log/ "$f"
done
You can use the continue command.
Also note that the variable picks up the whole path.
for f in folder/*.robot; do
test "$f" = folder/config.robot && continue
robot -b debug.log -d log/ "$f"
done
edited Jan 29 at 19:51
Stéphane Chazelas
305k57574927
305k57574927
answered Jan 29 at 18:15
Ken JacksonKen Jackson
312
312
add a comment |
add a comment |
Try this,
for test_file in folder/*.robot;
do
[ "$test_file" != "config.robot" ] && robot -b debug.log -d log/ $test_file.robot;
done
robotwill run only if$test_fileis not equal toconfig.robot
or simple using find
find folder/*.robot ! -name "config.robot" -exec robot -b debug.log -d log/ {} +
Usingextglob(as in @sparhawk comment) is more efficient...
– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike theifsolution
– ilkkachu
Jan 29 at 18:23
find folder/*.robot ...works but is a bit odd. You'd usually usefind . -name "*.robot" ! -name "config.robot" -exec ...Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...
– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the originalsh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.
– xenoid
Jan 29 at 23:48
add a comment |
Try this,
for test_file in folder/*.robot;
do
[ "$test_file" != "config.robot" ] && robot -b debug.log -d log/ $test_file.robot;
done
robotwill run only if$test_fileis not equal toconfig.robot
or simple using find
find folder/*.robot ! -name "config.robot" -exec robot -b debug.log -d log/ {} +
Usingextglob(as in @sparhawk comment) is more efficient...
– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike theifsolution
– ilkkachu
Jan 29 at 18:23
find folder/*.robot ...works but is a bit odd. You'd usually usefind . -name "*.robot" ! -name "config.robot" -exec ...Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...
– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the originalsh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.
– xenoid
Jan 29 at 23:48
add a comment |
Try this,
for test_file in folder/*.robot;
do
[ "$test_file" != "config.robot" ] && robot -b debug.log -d log/ $test_file.robot;
done
robotwill run only if$test_fileis not equal toconfig.robot
or simple using find
find folder/*.robot ! -name "config.robot" -exec robot -b debug.log -d log/ {} +
Try this,
for test_file in folder/*.robot;
do
[ "$test_file" != "config.robot" ] && robot -b debug.log -d log/ $test_file.robot;
done
robotwill run only if$test_fileis not equal toconfig.robot
or simple using find
find folder/*.robot ! -name "config.robot" -exec robot -b debug.log -d log/ {} +
edited Jan 29 at 18:14
ilkkachu
58.3k890164
58.3k890164
answered Jan 29 at 10:36
msp9011msp9011
4,31844065
4,31844065
Usingextglob(as in @sparhawk comment) is more efficient...
– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike theifsolution
– ilkkachu
Jan 29 at 18:23
find folder/*.robot ...works but is a bit odd. You'd usually usefind . -name "*.robot" ! -name "config.robot" -exec ...Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...
– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the originalsh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.
– xenoid
Jan 29 at 23:48
add a comment |
Usingextglob(as in @sparhawk comment) is more efficient...
– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike theifsolution
– ilkkachu
Jan 29 at 18:23
find folder/*.robot ...works but is a bit odd. You'd usually usefind . -name "*.robot" ! -name "config.robot" -exec ...Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...
– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the originalsh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.
– xenoid
Jan 29 at 23:48
Using
extglob (as in @sparhawk comment) is more efficient...– xenoid
Jan 29 at 10:57
Using
extglob (as in @sparhawk comment) is more efficient...– xenoid
Jan 29 at 10:57
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike the
if solution– ilkkachu
Jan 29 at 18:23
@xenoid, efficient in what way? If you mean in terms of CPU time used, the difference is quite likely to be totally negligible. If you mean in terms of readability or such, do note that not everyone might be familiar with ksh-style extended globs, and they're not standard anyway, unlike the
if solution– ilkkachu
Jan 29 at 18:23
find folder/*.robot ... works but is a bit odd. You'd usually use find . -name "*.robot" ! -name "config.robot" -exec ... Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...– ilkkachu
Jan 29 at 18:27
find folder/*.robot ... works but is a bit odd. You'd usually use find . -name "*.robot" ! -name "config.robot" -exec ... Of course, the latter would recurse to subdirectories, and would not keep the filenames in numerical order, while the former does exactly the opposite...– ilkkachu
Jan 29 at 18:27
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the original
sh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.– xenoid
Jan 29 at 23:48
Fewer processes and shorter code. "Not everyone can be familiar...": yes, but everyone can/should learn a new trick from time to time otherwise we would still all be using the original
sh. My skills improve because when I see some code I don't recognize, I try to understand where that comes from and if I can use it myself.– xenoid
Jan 29 at 23:48
add a comment |
Related: exclude a file from a glob
– Sparhawk
Jan 29 at 10:40
1
@avazula, if you get the pattern literally back from a glob, it means the pattern didn't match anything (and you didn't have nullglob or failglob set). You may want to check the exact commands you run and the files you have to see that they actually match. E.g. try what
touch foo.robot bar.robot config.robot; shopt -s extglob; for f in ./!(config).robot; do echo "file: $f"; donedoes in an empty directory, it should print the names offoo.robotandbar.robot.– ilkkachu
Jan 29 at 18:21
GNU
findhas its peculiar approach to regular expressions. It supports several regex types, defaulting toemacs. Also, note thatfindregular expressions must match whole paths, not just file names. For instance, if you are familiar with BRE, and assuming your files are in./folder(relative to the current directory), you may usefind . -regextype posix-basic -regex './folder/[0-9]{2}[-A-Za-z_]{1,}.robot'. Nevertheless, this approach is really fragile and not advisable. Getting globbing right is the way to go.– fra-san
Jan 29 at 18:53
Regarding you edit: You tagged the question with bash. If this is not what your framework thingy uses, then please figure out what shell it uses and re-tag the question appropriately. Jeff's answer is correct for
bash.– Kusalananda
Jan 29 at 19:42
Any other shell than Bash would probably not have
shopt, and the parenthesis in the glob would likely be a syntax error if extended globs weren't supported. (Except that it seems a valid glob in Zsh, but then Zsh would by default complain about a glob that didn't match anything so there wouldn't be an error fromrobot.)– ilkkachu
Jan 29 at 20:04