I wanted a little script which would take a text file and output letter groups of five. This is for no real reason other than problem solving. Along the way, I discovered a useful bash command called 'fold' which does line breaks. I also discovered a command called 'jot' - but that is of little use to me here!
[sourcecode language="bash"] #!/bin/bash # Will group text into five letter groups echo "If you have not specified a file, type your input, when done, enter ctrl-D" echo "" # The 'cat "$@"' construction gets input either from stdin or from files. # If using stdin, terminate input with a Control-D. # Otherwise, specify filename as command-line parameter. cat "$@" | tr -d "\n" | tr -cd '[:alpha:]' | tr "a-z" "A-Z" | sed 's/\([[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]][[:alpha:]]\)/\1 /g' | fold -s -w 40 exit 0 [/sourcecode]
The command produces output like this:
If you have not specified a file, type your input, when done, enter ctrl-D I typed: The Quick Brown Fox Jumps Over The Lazy Dog. And Where's that silly dog? Under the Fox! Under the Fox! And where's that dastardly Fox? Above the Dog! Above the Dog! here I typed ctrl-D THEQU ICKBR OWNFO XJUMP SOVER THELA ZYDOG ANDWH EREST HATSI LLYDO GUNDE RTHEF OXUND ERTHE FOXAN DWHER ESTHA TDAST ARDLY FOXAB OVETH EDOGA BOVET HEDOG
Now I want to work out how to do a Vigenere coding on the command line. I honestly don't see how to do this at the moment.