Double Space, Triple Space ...

Here are handy scripts for printing drafts of files. They double-space or triple-space file(s) or standard input. For example:

% doublespace afile | lp % prog | triplespace | lp


doublespace
triplespace
Here they are:


doublespace triplespace #!/bin/sed -f #!/bin/sed -f G G G

No, that isn't a typo: both scripts just use the sed command G (). The G command appends a newline and the contents of sed's hold space, which will be empty in this script. The effect is to add a newline after every newline; two Gs add two newlines.

That file doesn't even use a shell, so it's efficient; the kernel starts sed directly () and gives it the script itself as the input file expected with the -f option. If your UNIX can't execute files directly with #!, type in these versions instead:

doublespace triplespace exec /bin/sed G ${1+"$@"} exec /bin/sed 'G;G' ${1+"$@"}

They start a shell, then exec replaces the shell with sed (). The ${1+"$@"} works around a problem with argument handling () in some Bourne shells.

And now you know how to make quadruplespace, quintuplespace, ... :-).

- JP