by geophile · 6y ago · 0 comments
ls -fr \
| select (f: f.suffix in ('.c', '.h')) \
| map (f: f.read().count('\n')) \
| red +
- List only files (-f) recursively (-r).- Select those whose suffix is .c or .h.
- Map qualifying files to the count of \n in the file.
- Reduce those counts to a total using +.
The parentheses delimit Python functions (marcel permits omission of "lambda").
judging by the nickname and github url it's yours https://github.com/geophile/marcel
That's unfortunate, because as awful as bash may be, a shell that works natively on all three systems would be far more valuable. Python has all that platform abstraction already built-in.
If a xonsh user does want to do strict separation, how does that work? Syntactically, how do you separate shell code from Python code?