[TUHS] The most surprising Unix programs
rtomek at ceti.pl
Fri Mar 20 06:01:20 AEST 2020
On Tue, Mar 17, 2020 at 09:03:41AM -0400, ca6c at firemail.cc wrote:
> Doug McIlroy wrote:
> >The math library for Bob Morris's variable-precision desk
> >calculator used backward error analysis to determine the precision
> >necessary at each step to attain the user-specified precision of
> >the result. In my software-components talk at the 1968 NATO
> >conference on software engineering, I posited measurement-standard
> >routines, which could deliver results of any desired precision, but
> >did not know how to design one. dc still has the only such routines
> >I know of.
> dc, along with ed and I guess awk if we can put it here, is one of my
> favorite Unix programs that I use daily. I don't even have a "normal"
> calculator installed. It just smells like Unix.
+1 for (g)awk. After learning it and for many many years treating as
"oh just a lines of text processing" tool, I have rediscovered it
about a year or two ago. It is (IMHO) a very good alternative language
for writing scripts whose complicated control flow might make sh
script error-prone and/or ugly. One such script helps me with sound
processing - doing some tests for recorded file, composing params for
invocation of ecasound (say, check if file needs to be recoded from
48kHz to 44.1kHz etc), and, whoa, invoking ecasound and streaming
bytes to stdout for ogg encoder. The script is part of a pipeline,
takes multiple filenames as args and cats them one by one, each with
the right incantation to ecasound - amplification level, freq changes,
all auto, so much modern, look ma no hands :-).
Another one is changing color temperature of my monitor. I have found
function computing RGB values in someone's code, and the colors were
not what I wanted. So the script also has some named profiles in a
hash table, where values are a line of three floats, which then gets
split()-ed and so on.
Overally, I would consider using (g)awk whenever there is a need to
invoke some commands based on quirky and complicated criteria. I am
sure the scripts could be written in "pure" sh, but something had me
step back from this.
One task I would be afraid to use awk for, is html processing. Most of
html sources I look at nowadays seems discouraging. Extracting
anything of value from the mess requires something more potent, I
> There is something sexy about reverse Polish notation. I really do
> encourage everyone reading this to try dc as their "desk calculator"
> for some time.
For "desk calculator" I am using clisp, a (relatively) lightweight
Common Lisp interpreter. I got hooked up after discovering that CL had
quite a few numeric types - real rational numbers. making 1/3 and 1/10
easy to have in computer, few floating types, "unlimited" ints,
complex numbers. One has to be wary about unintended type conversion,
but otherwise I found it very useful for my needs.
And for "smart calculator" in a pocket, I would like to use gforth
implementation for Android. Once I make myself comfy enough with Forth
to not have to poke around manual all the time.
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** Tomasz Rola mailto:tomasz_rola at bigfoot.com **
More information about the TUHS