List only directories names which match a pattern
You are probably after the -d
switch of ls
:
ls -d *pattern*/
ls --directory *pattern*/
Use this little hack:
printf '%s\n' *pattern*/
if you prefer all on the same line :
echo *pattern*/
or using bash array :
arr=( *pattern*/ )
printf '%s\n' "${arr[@]%/}"