5 ms·
I have a very dumb question: why does the article use `find` with `printf` and depth specification, as opposed to the simpler `ls -a`? I'm assuming it has somet
by tooltower 4y ago
I have a very dumb question: why does the article use `find` with `printf` and depth specification, as opposed to the simpler `ls -a`? I'm assuming it has something to do with portability, but `ls -a` is already in POSIX. I'm a bit confused.
- deleted 4y ago[deleted]
- johnchristopher 4y agoHmm. I think it's because `ls -a` will not visually differentiate between files and folders and will also show `.`and `..`. and will span contents over columns while find will return a line by found items. Or they are a show-off.
- lovelymono 4y agoThey could have used ls -A -1 -p which should result in the same output. -A is like -a but will not print . and .. directories. -1 prints one file per line. -p appends / to directories. There's a lot more flags in the man page: https://man7.org/linux/man-pages/man1/ls.1.html https://man7.org/linux/man-pages/man1/ls.1.html
- yjftsjthsd-h 4y agoThat's GNU ls; AFAICT -1 and -p aren't POSIX so might not work on other unix-likes (most prominently Darwin, but also the BSDs)
- lovelymono 4y agohttps://pubs.opengroup.org/onlinepubs/009696899/utilities/ls.html https://pubs.opengroup.org/onlinepubs/009696899/utilities/ls... lists both -p and -1. And while -p is marked as an XSI extension, both Darwin and all modern BSD distributions implement it.
- yjftsjthsd-h 4y agoHuh, good catch. Not sure why `man 1p ls` didn't give me that:\
- yesco 4y agohttps://mywiki.wooledge.org/ParsingLs https://mywiki.wooledge.org/ParsingLs