how does echo recognize, when it should output list of files or pure text?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I encountered this question in my test:
Make echo output all directories that start with a vowel (a,e,i,o,u,e), end with a number and have at least 3 characters. I thought this would be fairly easy, but soon I ended up confused and evetually failed the test.
My first thought was simply:
echo a,e,i,o,u,e*0..9
Then I tried to use square brackets
echo [a,e,i,o,u,e]*[0..9]
and at the end i tried something like this:
echo $(ls a,e,i,o,u,e*0..9)
which gave me the required output, but with some error directory missing messages, and Im not even sure if it wouldnt be considered cheating as Im using another function to do it.
Could anyone clarify for me, how do I do it and when do I use which brackets?
And I would also like to know, how does echo recognize when it should output list of directories instead of my exact words.
wildcards echo
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
0
down vote
favorite
I encountered this question in my test:
Make echo output all directories that start with a vowel (a,e,i,o,u,e), end with a number and have at least 3 characters. I thought this would be fairly easy, but soon I ended up confused and evetually failed the test.
My first thought was simply:
echo a,e,i,o,u,e*0..9
Then I tried to use square brackets
echo [a,e,i,o,u,e]*[0..9]
and at the end i tried something like this:
echo $(ls a,e,i,o,u,e*0..9)
which gave me the required output, but with some error directory missing messages, and Im not even sure if it wouldnt be considered cheating as Im using another function to do it.
Could anyone clarify for me, how do I do it and when do I use which brackets?
And I would also like to know, how does echo recognize when it should output list of directories instead of my exact words.
wildcards echo
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
you should useecho [aeiou]?*[0-9]
â mosvy
25 mins ago
a,eand0..9braces will expand even if there are no files matching them,[a,e]and[0..9]are not the proper way to write a glob range (the latter will match0,.and9), but[ae]and[0-9], and[ae]*[0-9]will also match filenames of two characters, thence?*instead of*.
â mosvy
16 mins ago
1
echocan't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.
â roaima
3 mins ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I encountered this question in my test:
Make echo output all directories that start with a vowel (a,e,i,o,u,e), end with a number and have at least 3 characters. I thought this would be fairly easy, but soon I ended up confused and evetually failed the test.
My first thought was simply:
echo a,e,i,o,u,e*0..9
Then I tried to use square brackets
echo [a,e,i,o,u,e]*[0..9]
and at the end i tried something like this:
echo $(ls a,e,i,o,u,e*0..9)
which gave me the required output, but with some error directory missing messages, and Im not even sure if it wouldnt be considered cheating as Im using another function to do it.
Could anyone clarify for me, how do I do it and when do I use which brackets?
And I would also like to know, how does echo recognize when it should output list of directories instead of my exact words.
wildcards echo
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I encountered this question in my test:
Make echo output all directories that start with a vowel (a,e,i,o,u,e), end with a number and have at least 3 characters. I thought this would be fairly easy, but soon I ended up confused and evetually failed the test.
My first thought was simply:
echo a,e,i,o,u,e*0..9
Then I tried to use square brackets
echo [a,e,i,o,u,e]*[0..9]
and at the end i tried something like this:
echo $(ls a,e,i,o,u,e*0..9)
which gave me the required output, but with some error directory missing messages, and Im not even sure if it wouldnt be considered cheating as Im using another function to do it.
Could anyone clarify for me, how do I do it and when do I use which brackets?
And I would also like to know, how does echo recognize when it should output list of directories instead of my exact words.
wildcards echo
wildcards echo
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 7 mins ago
Rui F Ribeiro
37.2k1274118
37.2k1274118
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 30 mins ago
Meio
41
41
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Meio is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
you should useecho [aeiou]?*[0-9]
â mosvy
25 mins ago
a,eand0..9braces will expand even if there are no files matching them,[a,e]and[0..9]are not the proper way to write a glob range (the latter will match0,.and9), but[ae]and[0-9], and[ae]*[0-9]will also match filenames of two characters, thence?*instead of*.
â mosvy
16 mins ago
1
echocan't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.
â roaima
3 mins ago
add a comment |Â
1
you should useecho [aeiou]?*[0-9]
â mosvy
25 mins ago
a,eand0..9braces will expand even if there are no files matching them,[a,e]and[0..9]are not the proper way to write a glob range (the latter will match0,.and9), but[ae]and[0-9], and[ae]*[0-9]will also match filenames of two characters, thence?*instead of*.
â mosvy
16 mins ago
1
echocan't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.
â roaima
3 mins ago
1
1
you should use
echo [aeiou]?*[0-9]â mosvy
25 mins ago
you should use
echo [aeiou]?*[0-9]â mosvy
25 mins ago
a,e and 0..9 braces will expand even if there are no files matching them, [a,e] and [0..9] are not the proper way to write a glob range (the latter will match 0, . and 9), but [ae] and [0-9], and [ae]*[0-9] will also match filenames of two characters, thence ?* instead of *.â mosvy
16 mins ago
a,e and 0..9 braces will expand even if there are no files matching them, [a,e] and [0..9] are not the proper way to write a glob range (the latter will match 0, . and 9), but [ae] and [0-9], and [ae]*[0-9] will also match filenames of two characters, thence ?* instead of *.â mosvy
16 mins ago
1
1
echo can't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.â roaima
3 mins ago
echo can't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.â roaima
3 mins ago
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Meio is a new contributor. Be nice, and check out our Code of Conduct.
Meio is a new contributor. Be nice, and check out our Code of Conduct.
Meio is a new contributor. Be nice, and check out our Code of Conduct.
Meio is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476897%2fhow-does-echo-recognize-when-it-should-output-list-of-files-or-pure-text%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
you should use
echo [aeiou]?*[0-9]â mosvy
25 mins ago
a,eand0..9braces will expand even if there are no files matching them,[a,e]and[0..9]are not the proper way to write a glob range (the latter will match0,.and9), but[ae]and[0-9], and[ae]*[0-9]will also match filenames of two characters, thence?*instead of*.â mosvy
16 mins ago
1
echocan't differentiate files from directories, so your test can only be completed successfully if there is an implicit understanding that there are only directories that will match your wildcard pattern.â roaima
3 mins ago