#!/bin/bash ## filter to convert a list of words from space-separated to one-per-line form; by Eugene Reimer 2008-11: tr ' ' '\n' ##translate space->newline, producing the canonic form provided the input had a terminating space or newline but not both exit Note: the one-per-line format is well-defined, however space-separated comes in 2 flavours: with or without an ending newline; and some may well use space-terminated instead also in with-or-without-ending-newline variants; so this script might well be improved by handling all 4 of those variants as input while producing a canonic form as output? However my little scripts all produce space-separated in the with-ending-newline form, so it doesn't seem necessary. Furthermore, a list being non-canonic only in its whitespace characters is not likely to matter. Or rather, it's not likely to be a serious flaw; to me it often matters and having guessed incorrectly about whether or not some routine's idea of a string includes a terminating newline has frequently been one of those minor flaws that although not at all serious did still mean messy-looking info- or error-messages that were just barely serious enough to make me go back to correct the assumption. But why does space-separated form have an ending newline? Naming: my first thought was to call these 2 little routines CvtOnePerLineToSpaceSeparated and CvtSpaceSeparatedToOnePerLine, but having a routine's name be longer, by 2:1 yet, than the code it replaces seems wrong to me, so I settled on sp2nl and nl2sp, although these short names may make the convention regarding the terminating character come as a surprise.