What command is used to list all files and directories in the current directory, where the second character of its name is a digit.
Can we use
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If you want to list all files whose second character is a digit, you can use Bash wildcards like this:
?represents any single character,
[0-9]represents any single character in the range
9, and finally
*represents any number of characters.
To list such files on the terminal you can use
ls, or any other command that will output its parameters. For example:
ls -d ?[0-9]*
In the first case (
ls), we need to add the
-d parameter to list directories themselves, not their contents, in case that the file name we "match" is actually a directory.