This must already exist
lbrandy.com
lbrandy.com
$ apropos pipe
IO::Pipe (3p) - supply object methods for pipes
perlipc (1) - Perl interprocess communication (signals, fifos, pipes, safe subprocesses, sockets, and semaphores)
pipe (2) - create descriptor pair for interprocess communication
***tee (1) - pipe fitting***
funzip (1) - filter for extracting from a ZIP archive in a pipe
pv (1) - monitor the progress of data through a pipe
I find it helpful to run the following once in a while: $ for f in $(ls $BINPATH); do whatis $f >> funs; done
(where BINPATH is /bin, /usr/bin, /usr/local/bin, etc.), skim through the list of utilities, and look at the man pages for anything unfamiliar.As with Emacs, the tool you want probably already exists, and you may already have it installed, you just need to search with the right keyword. (Learning the terminology takes some time, though.) Any system with that many features is difficult to completely remember, but remembering the details can also get pushed onto the system.
It beats the pants off of google/apropos/anything else simply because the type signatures for functions in a purely-functional, statically-typed language practically tell you what the function does!
Hoogle is a search engine for haskell's standard libraries, and lets you search by name, or type signature. It even helps you discover abstractions that you never knew about before:
Come to think of it, apropos could also search Haskell functions by type signature -- Haddock would just need to generate stub man pages for them. (I don't use Haskell anymore, but someone might find it useful.)
Incidentally, the pipe-able Unix utilities are so useful because they all have the same type (line-buffered text stream -> line-buffered text stream), which is a particularly easy one to use across languages.
$ for f in ${BINPATH}/*; do whatis "$(basename $f)" >> funs; doneFor a more heavyweight alternative, there are lots of solutions around for running batches of commands across multiple machines. For most/all of these, multiple commands on a single machine are just one of the simpler cases they can handle. Systems that spring to mind are GridEngine (http://gridengine.sunsource.net), Qube (http://www.pipelinefx.com) and Condor (http://www.cs.wisc.edu/condor). There are plenty of others too (including a lot of home-brewed brewed systems knocking around inside VFX houses).
It comes down to the idea that the command line is a "non-discoverable" interface. If you don't know what you want, there's pretty much no way to find it.
Any suggestions how to fix that? Google solves a lot of them, but not all. Having said that, I've had fair success recently with just typing entire questions into it as if it were a programmer I'm talking to ...
It buffers child process output and emits it when the child completes - this keeps concurrent process output from being as confusing.
Those were features I wanted at the time and '&' with wait didn't provide them.
I have, however, done this before. I have a "load_wait" command which waits for machine load to drop below a certain level before launching the command. A simple "sleep 1" between instances of that then lets me launch thousands of commands without killing the machine.
sleep 1 ; load_wait 3 <command1> &
sleep 1 ; load_wait 3 <command2> &
sleep 1 ; load_wait 3 <command3> &
sleep 1 ; load_wait 3 <command4> &
...
I then launch those via "system" from inside awk and I'm done. The commands tend to be in muscle memory.For example, if I'd been searching for the "pipe thingy" lbrandy's blog entry starts out searching for, I might have typed "apropos pipe", and lo and behold, there it is at the bottom of the list:
...
pipe(2) - create descriptor pair for interprocess communication
pipe(8) - Postfix delivery to external command
rotatelogs(8) - Piped logging program to rotate Apache logs
tee(1) - pipe fitting
"pipe fitting" isn't the most useful description, but given how few other things there are, it's not too many man pages to read, especially after culling out the things I already knew about back when I didn't yet know about tee(1). tee (2) - duplicating pipe content
tee (1) does not show up in the search for pipe, but it's description is: tee (1) - read from standard input and write to standard output and filesInteresting that you would say that, as I have a friend who works for Google who would like to use machine learning techniques to make a better command line.
It also seems to me that Google's "one box" interface for Chrome, where pretty much no matter what you want to do you just start typing something in the address bar, is maybe the best approximation for what you would want a really good command line interface to look like.
http://asymmetrical-view.com/personal/code/perl/parallel-jobs.readme
http://asymmetrical-view.com/personal/code/perl/parallel-jobs
Example 'command file':
# specify several downloads to be run in parallel
wget http://some.host/software.tar.gz
wget http://some.host/database.mdb
wget http://some.host/movie-trailer.mpeg
wget http://some.host/linux-distrubtion.isoRun as:
parllel-jobs --cmdfile=file.cmd --maxjobs=4Maybe we could figure out a thingy that watches what you're doing and finds ways to do it better.
For instance, I'm looking for an iPhone app that let's you take pictures of people, add names and details, and let's you browse them by picture. I bet something like it exists, but I can't find it.
"I see you're trying to create an implementation of half of common lisp."
To a certain extent, this is somewhere where GUIs out-perform command lines - the hierarchical menu system that shows you the functionality available in a way that's fairly easily searchable. Maybe you could implement some sort of tree-structured help on the CLI?
#!/bin/perl
use Parallel::ForkManager;
$pm = new Parallel::ForkManager(4);
while ($filename = <*.jpg>) {
$filename =~ s/.jpg//;
$pm->start and next;
system("convert $filename.jpg -resize 320x240 $filename-sm.jpg");
$pm->finish;
}At that point, I'd just use awk, though. It has better defaults for field delimiters.
by "flatten the whitespace" do you mean turning many spaces into one space? If so, I have always used tr with the -s (squeeze) option for that:
$ echo "one two three" | tr -s " " | cut -d " " -f 3
three