4 ms·
But you don't actually want to parse them though, that's the mechanism by which you receive the data but the real end goal is you just want the data in its cano
by shatteredgate 5y ago
But you don't actually want to parse them though, that's the mechanism by which you receive the data but the real end goal is you just want the data in its canonical format so it can used programmatically; in powershell there is no parsing, the output is always the canonical representation.
I don't get what you meant in the last sentence, the underlying API is glibc which is also cross platform and is incredibly well known. Other cross-platform languages like Java, Golang, Rust, etc have their own portable APIs to enumerate directories that are cross platform.
- AtlasBarfed 5y agoPerl. Python. Bash or shell scripts. They all have "invoke this shell command" at a minimum. Then you get into ssh and a host of other command invocations to get information. The shell is the convenient way to invoke commands to get the information: locally, remotely, quickly, no setup of C bindings, lots of invocation options. If you are polyglot, do you want to use a command you know (ls) or learn each language's infernal syntax for filtering, recursive listing, etc, or learn it once with shell?
- shatteredgate 5y ago>If you are polyglot, do you want to use a command you know (ls) or learn each language's infernal syntax for filtering, recursive listing, etc, or learn it once with shell? Probably learn the language's syntax because it's faster and more powerful, e.g. in python and perl I'd say don't bother with running shell commands and doing unnecessary forking and parsing if you can avoid it, use the built-in glob instead: https://docs.python.org/3/library/glob.html https://docs.python.org/3/library/glob.html https://perldoc.perl.org/functions/glob https://perldoc.perl.org/functions/glob Most languages just have this now because it's easier and faster than invoking external programs and is a better cross platform solution, glibc even has it: https://man7.org/linux/man-pages/man3/glob.3.html https://man7.org/linux/man-pages/man3/glob.3.html