K
K
Kirill Kirik2021-04-13 12:57:08
linux
Kirill Kirik, 2021-04-13 12:57:08

How to display a list of files in a directory whose name starts with the given characters?

What parameters of the ls command should be used to list the files in a directory whose name starts with the given characters (letters)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lynn "Coffee Man", 2021-04-13
@KoyaKoya

The command is called ls .
She has no such options.
But if you've seen something like ls a* somewhere, it will most likely work as you want, not because ls is so smart, but because your shell has replaced a* with a list of files starting with a . You might as well write echo a* and see the same list.

V
Vasily Bannikov, 2021-04-13
@vabka

You can write
ls | grep ^[abc]
Print to the console all files in the current directory that start with a,b or c
or
ls | grep ^abc- print all files that start with abc
There is no option for regular expressions in ls itself.

S
Saboteur, 2021-04-13
@saboteur_kiev

write

ls -d a*
ls -d b*
ls -d abc*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question