by gray_-_wolf · 6y ago · 0 comments
+ $ find /tmp/x ! -path /tmp/x -prune -type f -exec sh -c 'for p; do printf '\''%s\n'\'' "${p##*/}"; done' - {} +
c
b
a
Seems to do the trick and is POSIX only (so works on busybox and mac). You can probably just tack `| sort` at the end if you want it sorted.People value software that's easy to use. That command you typed is a Frankenstein's monster.
fls () {
find . -maxdepth 1 -type f
}
vs fls () {
find . ! -path . -prune \
-type f \
-exec sh -c 'for p; do printf '\''%s\n'\'' "${p##*/}"; done' - {} +
}
The user would just type `fls` in the directory they were exploring.