|
|
Subscribe / Log in / New account

Poettering: Revisiting how we put together Linux systems

Poettering: Revisiting how we put together Linux systems

Posted Sep 5, 2014 14:42 UTC (Fri) by mathstuf (subscriber, #69389)
In reply to: Poettering: Revisiting how we put together Linux systems by NightMonkey
Parent article: Poettering: Revisiting how we put together Linux systems

True, but I've found that the limit is very easy to meet for it to make sense in non-shell code. In fact, the case I'm referencing was actually *much* better in Python (even though it was 300+ lines afterwards) because we went from 3n+l stat calls (n == number of files, l == number of symlinks) to n+l because we could remember more than one thing at a time. Plus someone other than I could grok it in 5 minutes. That kind of change is something just not possible in shell code. Hell, I had to do "awk | awk" because system() output in awk only goes to stdout, not to a variable.


to post comments

Poettering: Revisiting how we put together Linux systems

Posted Sep 7, 2014 17:45 UTC (Sun) by jwakely (subscriber, #60262) [Link] (1 responses)

> Hell, I had to do "awk | awk" because system() output in awk only goes to stdout, not to a variable.

You can use awk's pipe operator instead:

cmd = "ls -l";
while ((cmd | getline x) == 1) xx = xx x "\n";
close(cmd);

Poettering: Revisiting how we put together Linux systems

Posted Sep 8, 2014 5:15 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

That should have a "see also" near the docs for system() in awk's manage. Thanks for the info at least.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds