Ls command options

Hi,

If I want to list files with names containing a certain letter like " a " using just one ls command, is there any way of doing that?

Note that it is containing a letter instead of one of the following (starting, ending with a letter or having the letter in between). what I want is to show all the three combinations together using one ls command.

All of the following assume that you are not looking for "hidden" files (i.e., files with names starting with a period)... For files with names containing "a":

ls -d -- *a*

For files with names starting with "a":

ls -d a*

For files with names ending with "a":

ls -d -- *a

For files with names containing "a" but not as the first or last character:

ls -d -- [^a]*a*[^a]
1 Like