Live data from Hacker News

The most surprising Unix programs

minnie.tuhs.org

171–180 of 182 posts

Re: The most surprising Unix programs

#171
post #114

Earlier quoted context omitted.

Recently I found myself wanting to stop a program after a certain timeout. I found myself thinking "sure there's a UNIX program to do this in shell?" There is. And it's called... brace yourself... "timeout". 20+ years in UNIX, never encountered it. Part of GNU coreutils.

Sometimes good to use for cron jobs so that the previous one won't keep running on top of the current run. You should debug for it to not happen though but probably better than seeing your system choke with dozens of instances even slowing the jobs more. There's also "run-one" that allows you to control which job should survive instead of just killing the old one. http://manpages.ubuntu.com/manpages/trusty/man1/run-o…

If you're using systemd timers, you get this behavior for free because those timers only activate service units. If the service is already active, nothing happens.

(Of course, this can be surprising in a different way when you expect a new job to start, but it does not because a previous one is still lingering. Not saying it's better or worse, just pointing out for those who don't know.)

Re: The most surprising Unix programs

#172
post #24

« Typo was as surprising inside as it was outside. Its similarity measure was based on trigram frequencies, which it counted in a 26x26x26 array. The small memory, which had barely room enough for 1-byte counters, spurred a scheme for squeezing large numbers into small counters. To avoid overflow, counters were updated probabilistically to maintain an estimate of the logarithm of the count. » This sounds like somethi…

Typo existed at least in Unix V5, with this source code: https://minnie.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/...

Unix V5 was released mid '70s, but as others have pointed out, counting is different from count distinct.

Re: The most surprising Unix programs

#173
post #16

It's surprising that Doug McIlroy still reads and writes about UNIX. For those who don't know, Dough is the guy that invented pipes.

Pedantic but I think important clarification: McIlroy proposed the concept of linking programs together in a pipeline. Ken Thompson created the notation and implementation we all know.

Re: The most surprising Unix programs

#174

I've written a few useful scripts that everyone should have. histogram - simply counts each occurrence of a line and then outputs from highest to lowest. I've implemented this program in several different languages for learning purposes. There are practical tricks that one can apply, such as hashing any line longer than the hash itself. unique - like uniq but doesn't need to have sorted input! again, one can simply h…

I work with csv files a lot. I have a short awk script which truncates/pads each column to a fixed width which I can specify at runtime. It also repeats the top column (headers) every 20 rows in a different ANSI color. I pipe the output to less -SR for interactive use so I can scan delimited data in a scrollable grid, with all columns aligned and labeled. I understand there's vim plugins for this, but, ehh.

There's also the likes of console-flat-table-viewer . One would have to convert the comma-separated stuff into one of the table types, but that's what Miller is for. (-:

* http://jdebp.uk./Softwares/nosh/guide/commands/console-flat-...

* http://johnkerl.org/miller/

Re: The most surprising Unix programs

#175
post #107

Earlier quoted context omitted.

I would guess, from experience of people doing things the hard way, at: * John A. Kunze's jot and rs * John Kerl's mlr ("Miller") * jq * join and comm, as mentioned * fmt * ex And, given what you just wrote: * printf

A handy one to add to your list is: seq[0] EDIT: I didn't see that you had already included 'jot' so removed it from my original reply. 0 - https://www.freebsd.org/cgi/man.cgi?query=seq&apropos=0&sekt...

I didn't include it because in my experience people don't overlook seq, whereas they do overlook jot. I only included things where I've encountered people overlooking such tools and doing things the hard way.

Re: The most surprising Unix programs

#176
post #82

sl ``` ( ) (@@) ( ) (@) () @@ O @ O @ O (@@@) ( ) (@@@@) ( ) ==== ________ ___________ _D _| |_______/ \__I_I_____===__|_________| |(_)--- | H\________/ | | =|___ ___| _________________ / | | H | | | | ||_| |_|| _| \_____A | | | H |__--------------------| [___] | =| | | ________|___H__/__|_____/[][]~\_______| | -| | |/ | |-----------I_____I [][] [] D |=======|____|________________________|_ __/ =| o |=-O=====O=====O=…

$ cowsay "hey dude" __________ ---------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

In your .bashrc (or whatever config file is run whenever you open up a new terminal).

fortune | cowsay

And voilà, you have a little quote running in your cow friend whenever you open up your terminal.

Also: Does anyone have any more good fortune files? I only have the fortunes that came preinstalled on Ubuntu but would love to have more.

Re: The most surprising Unix programs

#177

Earlier quoted context omitted.

$ cowsay "hey dude" __________ ---------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||

In your .bashrc (or whatever config file is run whenever you open up a new terminal). fortune | cowsay And voilà, you have a little quote running in your cow friend whenever you open up your terminal. Also: Does anyone have any more good fortune files? I only have the fortunes that came preinstalled on Ubuntu but would love to have more.

I like cowsay (especially cowsay -f dragon) for punching up important git commit messages.

Re: The most surprising Unix programs

#178
I have found it useful to survey the existing unix utilities (maybe every several years). I'm no genius but I find things I will use. One way of course is simply to review the names in wherever your system stores manual pages, and read (or skim) those where you don't know what they do, trying out some things, or trying to remember at least where to look it up later when ready to use it. Another is by browsing to https://man.openbsd.org/ , then put a single period (".") in the search field, optionally choose a section (and/or other system, not sure how far the coverage goes), and click the apropos button.

Re: The most surprising Unix programs

#179
post #152
post #107

Earlier quoted context omitted.

I would guess, from experience of people doing things the hard way, at: * John A. Kunze's jot and rs * John Kerl's mlr ("Miller") * jq * join and comm, as mentioned * fmt * ex And, given what you just wrote: * printf

Do I remember correctly that “jot” was also the name of a gui text editor on unix systems as well (different from the program referred to in the parent comment)? I think I used it in the early 90s on an SGI workstation running sun solaris OS.

Are you thinking of joe? https://joe-editor.sourceforge.io/
Post reply on HN