jodeci ross
jodeci ross

Reputation: 13

ls command for specific name convention

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.

Upvotes: 1

Views: 242

Answers (2)

EMottet
EMottet

Reputation: 310

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

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

Upvotes: 1

Philip Kirkbride
Philip Kirkbride

Reputation: 22879

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

Upvotes: 0

Related Questions