Rakesh Sharma <
shar...@hotmail.com>:
> On Thursday, 6 April 2017 04:45:13 UTC+5:30, Helmut Waitzmann wrote:
> find . -type d ! -name . -prune
>
> will print all the directories in the current dir.
Correct.
But if I understand the OP correctly, it is not exactly, what James
wanted. He asked for the output of
$ ls -d -- */
but with the trailing slashes removed. Admittedly, his example is
not complete: It contains neither a directory name (other than
“.” or “..”) starting with a dot nor a symbolic link referring to
a directory.
$ PS2='? '
$ mkdir -- test && cd test &&
? mkdir -- aa bb cc .dd &&
? ln -s -- . ee &&
? touch -- ff gg &&
? ls -d -- */
aa/ bb/ cc/ ee/
$ find . -type d ! -name . -prune
./bb
./.dd
./aa
./cc
$ find -L -- * ! -type d -o \( -prune -exec ls -d -- '{}' + \)
aa bb cc ee