I was trying to learn more about Linux and came across the command ls ????? and it displayed a few files in the directory but I am not really sure what it is specifically displaying. I tried to use the man to explain it further but I couldn't find anything. Could someone please explain?
Asked
Active
Viewed 609 times
1 Answers
-4
ls is a command on its own - try man ls for an explanation. ls ? may give a help summary in some Linux versions. ls with multiple ? is pointless as far as I know unless all the files listed have just five characters?.
-
I found that the ls ????? will display files/directories with names of 5 characters. If I wanted to search for a file that I know started with R and was 5 characters but didn't remember the name I would us ls R???? and that would give me everything in that directory matching those requirements. – rikito104 Jun 01 '20 at 17:49
-
1This question has very little to do with
ls
and much more to do with the question-marks... in fact, using a varying number of question marks demonstrates the point. – Jeff Schaller Jun 01 '20 at 17:50 -
It looks like it is matching for patterns, normally ls R* would give you any filenames of any length and R???? will do what you say. Perhaps look at man grep for more details on pattern matching. – Ralph_CCL Jun 01 '20 at 17:56
-
1
ls /?
would give a help summary... in DOS and Windows. (Except that the command there is calleddir
) I don't think I've ever seen/?
or-?
or such as giving a help text in any unix programs.?
by itself is a valid filename pattern (glob) for a one-letter filename, which you pretty much already know based on that last sentence.grep
uses regular expressions, they're not the same as glob patterns. See here for the latter: https://mywiki.wooledge.org/BashGuide/Patterns – ilkkachu Jun 01 '20 at 18:08
man 7 glob
. Also Is there a reason to use multiple question marks instead of an asterisk in filename expansion? – steeldriver Jun 01 '20 at 17:32man ls
but don't understand whatls ?????
is doing", and the other Q/A explains what the question-mark matches. I would love a better source-duplicate. – Jeff Schaller Jun 01 '20 at 19:24