This topic has been archived. It cannot be replied.
工作学习 / IT技术讨论 / A question to those DX who are proficiency in UNIX scripts
-goto(goto);
2002-1-26{401}(#348554@0)
Write a script to use the rot13 (rotate 13) algorithm to encrypt/decrypt a file. rot13 adds 13 to the letters (with wrap-around). So A-M convert to N-Z and N-Z convert to A-M. "Bat" would convert to "Nmg". The first parameter should be a file to convert if present. If not present convert stdin. The second parameter should be an output file name if present. If not the output should go to stdout.
Let me try ... BTW, "Bat" should be "Ong" not "Nmg" :)
-dennis2(Dennis);
2002-1-27{202}(#349294@0)
#!/bin/sh
if [ "X$1" = "X" ]
then
INPUT="-"
else INPUT=$1
fi
if [ "X$2" = "X" ]
then
OUTPUT=`tty`
else OUTPUT="$2"
fi