Score:5

Why doesn't the wildcard "?" work?

bn flag

I'm learning to use the terminal on Ubuntu with WSL. Right now I'm practicing wildcards, but the ? wildcard doesn't work for me.

As you can see, the * wildcard works but this one doesn't:

$ ls file*
file.html file.js file.txt
$ ls dot*
dot.txt dot1902.html dot2.txt
$ ls *.html
archivoPruebaClase.html dot1902.html file.html
$ ls dot?
ls: cannot access 'dot?': No such file or directory
$ ls index?
ls: cannot access 'index?': No such file or directory
njzk2 avatar
id flag
what do you expect it to do differently?
muru avatar
us flag
Please don't post screenshots of text. Copy the text here and use code formatting instead.
Score:14
id flag

I think it is working fine:

  • A * will be replaced with any number of characters on the command line.

  • A ? will be replaced by exactly one character.

So for example ls dot?.txt will show dot1.txt, dot2.txt, etc., but it wouldn’t for example show dot10.txt.

Try ls -a to list all files/folders in that folder and you can then work out what should be listed with your wildcard use.

Daniel Sierra avatar
bn flag
thank u. yep it took me like 3 hours but i figured out, yep just a noob mistake i was pretending to th terminal understood that i want the "filename" + ? but i completly ignore the extension, your answer just confirm my mistake, thank u a lot
NotTheDr01ds avatar
vn flag
@DanielSierra Easy mistake to make coming from Windows, which tends to "ignore" extensions in many cases. Linux itself actually doesn't even "understand" extensions, for the most part -- It's simply part of the filename here. It's us "humans" that tend to assign extensions on Linux for *our* organizational needs ;-).
Will avatar
id flag
@DanielSierra - that’s of course exactly what this site is for! It’s absolutely how to learn and how to use the site - have a go, try to work it out, if you get stuck ask. People here get irritated when people just post a question without trying but you did the opposite. I like answering these kinds of question because they make me check the advice I’m giving - and every now and then you get to learn something new in the process.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.