[Nottingham] Shell programming
Dan Mackdermott
dan at inputlink.net
Sat Dec 18 15:47:39 GMT 2004
On Sat, 18 Dec 2004, Martin wrote:
> Martin wrote:
> [...]
>>
>> function rot13
>> {
>> echo $@ | sed
>> y/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM/
>> }
>> export -f rot13
> [...]
>
> I left /that/ uglyness in there some drunken night?!!!
It may be ugly but it works! ;-)
> A little contest for the bashers: What's the shortest bash rot13 function?
It's not really bash but in one line?...
function rot13 { echo $@ | tr a-zA-Z n-za-mN-ZA-N; }; export -f rot13
> (OK, so sed is rather useful (:-))
...and perl...and awk...and etc etc :-p
Cheers,
Dan
--
Dan Mackdermott RHCE (Director)
InputLink Consulting Ltd
http://www.inputlink.net
t: +44 (0)115 988 1700
m: +44 (0)7980 711 557
More information about the Nottingham
mailing list