If you're familiar with the Unix or Linux commandline you probably know cat for printing files to standard output. Rot13 is a simple text encryption/cyphering/obfuscation (or whatever you want to call it) technique. It replaces each letter with the letter 13 places further in the alphabet. For example: 'a' becomes 'n', 'z' becomes 'm' and 'n' becomes 'a' (which illustrates the fact that the rot13 operation and its inverse are the same).
The following (very) simple bash script combines the functionality of cat with rot13 encryption. Save it to a file called catrot13 for example and store it to somewhere in your path.
#!/bin/bash cat "$@" | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]'
Usage example:
$> cat hello.txt
wello horld
how do you do?
$> catrot13 hello.txt
jryyb ubeyq
ubj qb lbh qb?
$> catrot13 hello.txt | catrot13
wello horld
how do you do?
$> catrot13 -n hello.txt
1 jryyb ubeyq
2 ubj qb lbh qb?The last command shows that you even can use the options of cat.
Post new comment