For example, in the /etc/ directory there are several files named rc0.d, rc1.d, rc2.d, rc3.d etc
lets say you want to list the permissions or the sizes of these directories while ignoring other directories that exist within /etc/
If we use that particular case, I've tried ls -al /etc/ | grep 'rc*.d'
this does not give the desirable output, I have also tried ls -al /etc/ | grep 'rc?.d'
which outputs nothing at all. if I do something like ls -al /etc/rc*?.d
this will instead list the files or directories that are within these directories not the directories themselves which is expected but it was a try.
The desired output would be something like:
drwxr-xr-x 2 root root 4096 Sep 6 03:11 rc0.d
drwxr-xr-x 2 root root 4096 Sep 6 03:11 rc1.d
drwxr-xr-x 2 root root 4096 Sep 6 03:24 rc2.d
drwxr-xr-x 2 root root 4096 Sep 6 03:24 rc3.d
drwxr-xr-x 2 root root 4096 Sep 6 03:24 rc4.d
drwxr-xr-x 2 root root 4096 Sep 6 03:24 rc5.d
drwxr-xr-x 2 root root 4096 Sep 6 03:11 rc6.d
Would appreciate some guidance, Thanks.
You need the -d
option to make ls
list directories themselves, not their contents. Ex.
ls -ld /etc/rc?.d
or
ls -ld /etc/rc[0-9].d
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments