In contrast, Unix is a Babel of different syntaxes. Every basic command like 'ls' has its own output syntax; every configuration file is in a different syntax. (Command line parsing isn't standardized either, but that train wreck deserves another conversation.)
In the case of the LispM all this was achieved by running the entire OS and all apps in a single address space; this obviously made passing objects between apps trivial, but at the price of a complete absence of security. Such a design would be a non-starter today. However, what you could do today would be to specify a standard system-wide serialization format, and give all the basic system commands an option to generate it. S-expressions would work great, but if you can't stand them, okay, use JSON. (Don't even think about using XML.)
The result would be, instead of just piping text strings from one app to another, you could, in effect, pipe objects. It's a far more powerful paradigm and would save you all this parsing pain.
Actually it's worse: they're byte streams. They don't have to be decodable as any encoding, can contain weird control characters, etc.
find ./ -type f -print0
Using the '-print0' option will output a null terminated list. Since Linux filenames can't contain nulls, you can reliably parse the output. find ./ -type f -print0 | xargs -0 ... for f in *; do
[[ -e $f ]] || continue
...
doneIn C, readdir returns a perfectly usable struct dirent * with no parsing issues to worry about.
Python also provides a usable Unix layer for automation.
ls pj* | wc -l
Which normally returns the number of pj* files, but will fail for pathological file names as the submission points out.Also, if you're creating filenames with newline and escape chars - well, good luck with that.
[simula67@hades test_bash]$ touch .hidden
[simula67@hades test_bash]$ touch not_hidden
[simula67@hades test_bash]$ find . -type f
./not_hidden
./.hidden
[simula67@hades test_bash]$ ls -al
total 8
drwxr-xr-x 2 simula67 simula67 4096 Jul 7 00:32 .
drwx------ 40 simula67 simula67 4096 Jul 7 00:31 ..
-rw-r--r-- 1 simula67 simula67 0 Jul 7 00:33 .hidden
-rw-r--r-- 1 simula67 simula67 0 Jul 7 00:33 not_hidden
[simula67@hades test_bash]$ for f in ; do echo $f; done
not_hidden
You have use shopt -s dotglob
[simula67@hades test_bash]$ shopt -s dotglob
[simula67@hades test_bash]$ for f in ; do echo $f; done
.hidden
not_hidden