List only directories names which match a pattern

find directories with pattern
regex match directory name
find all directories matching pattern linux
bash list directories into array
bash list all directories with name
list files matching pattern unix
ls only directories
linux list pattern

I'm bit confused about the command or modifiers to obtain: List of directories (only directories, not including subdirectories) which names include a pattern.

Thanks in advance.

You are probably after the -d switch of ls:

ls -d *pattern*/
ls --directory *pattern*/

Find all directories that contain a certain character and print them out , find /full/path/to/dir -name "*c*" -type d show 1 more comment If set, the pattern ** used in a filename expansion context will match all files and If the pattern is followed by a / , only directories and subdirectories match. Returns an enumerable collection of directory full names that match a search pattern in a specified path. EnumerateDirectories (String, String, EnumerationOptions) Returns an enumerable collection of the directory full names that match a search pattern in a specified path, and optionally searches subdirectories.

Try this :

printf '%s\n' *pattern*/

if you prefer all on the same line :

echo *pattern*/

or using bash array :

arr=( *pattern*/ )
printf '%s\n' "${arr[@]%/}"

ls: Display directory name when only one matches pattern, Possible workaround might be a wrapper function: dls() { if [ "$#" -eq 1 ] && [ -d "​$1" ]; then printf '%s:\n' "$1" fi ls -- "$@" }. The above function  Many times, we have to iterate over a list of files in a directory having names matching a pattern. In such a case, the glob module helps capture the list of files in a given directory with a particular extension. glob() function. This function fetches a list of files filtered based on the given pattern in the pathname.

That's works for me.

But it outputs also the directory characteristics, permissions, date, etc. and I want to display only the directory name.

ls -t | grep '^d' | grep 'pattern'

Linux / UNIX List Just Directories Or Directory Names, It will filter out directories name by matching first character ' d '. To reverse effect i.e. just to display files you need to pass the -v option. It invert  I'm bit confused about the command or modifiers to obtain: List of directories (only directories, not including subdirectories) which names include a pattern. Thanks in advance.

Linux see directory tree structure using tree command, -P pattern List only those files that match the pattern given. -I pattern --​matchdirs Include directory names in -P pattern matching. --noreport  Fig.01: List Directories in Unix and Linux Systems. Linux list only directories using ls command. Run the following ls command: ls -d */ Listing only directories using ls command in Linux or Unix-like systems. Linux Display or list only files. Type the following command to display list only files in Linux or Unix: $ ls -l | egrep -v '^d'

How to Search for Files and Folders via SSH, If you are uncertain about the file name or would like to match a part of the name, To only list the file names containing the string you are searching but omit the  Get-ChildItem -dir #lists only directories Get-ChildItem -file #lists only files If you prefer aliases, use. ls -dir #lists only directories ls -file #lists only files or. dir -dir #lists only directories dir -file #lists only files To recurse subdirectories as well, add -r option.

Linux tree command help and examples, tree lists the contents of directories in a tree-like format. It can be -P pattern, List only those files that match the wildcard pattern. Note: you  I am trying to get a list of files in a directory using Python, but I do not want a list of ALL the files. What I essentially want is the ability to do something like the following but using Pytho

Comments
  • A regular expression-style pattern? A glob-style pattern? Should this list be formatted to be unambiguously read by other tools (printf %s\0', with a reader expecting NUL-delimited input)? Formatted for human consumption (ls)? Formatted some other way?
  • The final commando erasing directories date, size and perm is: ls -l | grep '^d' | grep 'Castellano' | cut -c61-
  • @CharlesDuffy : Wrong place for your comment or wrong user ?
  • @JorgeVegaSánchez Please read mywiki.wooledge.org/ParsingLs to understand why this practice is extremely dangerous.
  • @JorgeVegaSánchez: I guess this is "a"
  • If you want only the names, that adds no advantage over printf '%s\n' */ (*/, unlike *, expands only to directories) -- but is far slower and potentially buggy.