5

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
jwodder
  • 727
  • 2
  • 7
  • 12

1 Answers1

14

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.

wjandrea
  • 14,109
  • 4
  • 48
  • 98
Will
  • 2,134
  • 5
  • 15
  • 32
  • 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 – Daniel Sierra Nov 14 '22 at 08:04
  • 9
    @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 ;-). – NotTheDr01ds Nov 14 '22 at 13:27
  • @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. – Will Nov 14 '22 at 14:25