How do you list the folder permissions of only certain directories that follow a common pattern in a particular directory?

basod3

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.

steeldriver

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do you use PHP to list the directories at the parent directory level?

From Dev

How to unzip only certain files that follow a specified pattern?

From Dev

how do you replace only a certain number of items in a list randomly?

From Dev

How to list only directories that are not on a `.git` directory subpath?

From Dev

How do I list (ls) the content of a folder/directory recursively but to a depth of only one folder/directory?

From Dev

Keeping only lines that follow a certain pattern

From Dev

How to list directories with particular depth?

From Dev

How do I set permissions on directory(folder) on IIS 6.0?

From Dev

How can I make git list only the tracked directories in a folder?

From Dev

mv: "Directory not Empty" - how do you merge directories with `mv`?

From Dev

How do I search in Windows using the wildcard but only in the particular folder?

From Dev

How do you create a directory with the same access permissions as an existing one?

From Dev

How do you fix file permissions for root directory?

From Dev

How do you fix file permissions for root directory?

From Dev

How do you create a directory with the same access permissions as an existing one?

From Dev

list only direct child directories of all directories with a particular name

From Dev

How do you change bullet/numbered list format of only certain parts?

From Dev

How to delete all files in particular folder present in current directory sub-folders excluding a certain file?

From Dev

How do you output a list of all man pages in a particular section?

From Dev

List only common parent directories for files

From Dev

List a directory but only if it contains sub-directories?

From Dev

List only regular files (but not directories) in current directory

From Dev

How do I get a list of only the files (not the directories) from a package?

From Dev

How do I get a list of only the files (not the directories) from a package?

From Dev

List the file permissions of only the current directory

From Dev

How do you compare only certain bits in data type?

From Dev

How do I list the files having particular strings from group of directories in bash?

From Dev

Find directories that do not contain a file in only directories proceeding a specific directory

From Dev

How do I get a count of files in a directory (recursively) but exclude directories with a certain name

Related Related

  1. 1

    How do you use PHP to list the directories at the parent directory level?

  2. 2

    How to unzip only certain files that follow a specified pattern?

  3. 3

    how do you replace only a certain number of items in a list randomly?

  4. 4

    How to list only directories that are not on a `.git` directory subpath?

  5. 5

    How do I list (ls) the content of a folder/directory recursively but to a depth of only one folder/directory?

  6. 6

    Keeping only lines that follow a certain pattern

  7. 7

    How to list directories with particular depth?

  8. 8

    How do I set permissions on directory(folder) on IIS 6.0?

  9. 9

    How can I make git list only the tracked directories in a folder?

  10. 10

    mv: "Directory not Empty" - how do you merge directories with `mv`?

  11. 11

    How do I search in Windows using the wildcard but only in the particular folder?

  12. 12

    How do you create a directory with the same access permissions as an existing one?

  13. 13

    How do you fix file permissions for root directory?

  14. 14

    How do you fix file permissions for root directory?

  15. 15

    How do you create a directory with the same access permissions as an existing one?

  16. 16

    list only direct child directories of all directories with a particular name

  17. 17

    How do you change bullet/numbered list format of only certain parts?

  18. 18

    How to delete all files in particular folder present in current directory sub-folders excluding a certain file?

  19. 19

    How do you output a list of all man pages in a particular section?

  20. 20

    List only common parent directories for files

  21. 21

    List a directory but only if it contains sub-directories?

  22. 22

    List only regular files (but not directories) in current directory

  23. 23

    How do I get a list of only the files (not the directories) from a package?

  24. 24

    How do I get a list of only the files (not the directories) from a package?

  25. 25

    List the file permissions of only the current directory

  26. 26

    How do you compare only certain bits in data type?

  27. 27

    How do I list the files having particular strings from group of directories in bash?

  28. 28

    Find directories that do not contain a file in only directories proceeding a specific directory

  29. 29

    How do I get a count of files in a directory (recursively) but exclude directories with a certain name

HotTag

Archive