1

I am trying to use the ls command to list specific subdirectories within a directory.

The subdirectories have the following name convention:

abc.wiki.git
abc.git
cde.wiki.git
cde.git
fgh.wiki.git
fgh.git

I would only like to list the subdirectories that do not have "wiki" within the name.

axiac
  • 68,258
  • 9
  • 99
  • 134
  • 3
    Possible duplicate of [List files not matching a pattern?](https://stackoverflow.com/questions/8525437/list-files-not-matching-a-pattern) – bishop Aug 29 '17 at 14:56

2 Answers2

1

I think for this use case, find is more clever.

$ find . -type d -not -name "*wiki*"

EMottet
  • 310
  • 1
  • 3
  • 14
0

If you want to see everything in said sub-folders you could use:

ls | grep -v wiki | xargs ls

If you don't want to see inside each subdirectory just use:

ls | grep -v wiki
Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225