I know I can do this to get a list of directory names:
find . -type d -maxdepth 1
The output looks like this:
.
./foo
./bar
I prefer the listing without ./
. Is there a way to get find to output just the raw names?
I tried sending the list to stat to format it but that just gives me the same result:
find . -type d -maxdepth 1 -print0 | xargs -0 stat -f '%N'
Best Answer
With GNU
find
you can use the-printf
option:As noted by Paweł in the comments, if you don't want the current directory to be listed add
-mindepth 1
, e.g.: