I have got a file with a single word on each line. Want to be able to make a comparison such that i can read pairs of words that are ROT13 to each other. Also, i would like to print the pairs to another file.
# cat rotfile
hello
world
uryyb
this
is
a
test
n
grfg
file
Following will pull out all matching rot 13 pairs:
# for x in `cat rotfile`; do y=`echo $x | tr '[a-z]' '[n-z][a-m]'`;if [ `grep $y rotfile` ]; then echo $x $y; fi; done | awk '{arr[$1]=$2;if ( arr[$2] != $1 ){print $0}}'
hello uryyb
a n
test grfg
Appreciate it !
Can understand it and it aint that complicated ! Its just that i am quite new to this type of programming and running out of time as this was just something I had to get out of the way !
What i did find out was that the error mesg - 'too many arguments' was due to having numbers in the file as well, instead of just characters !
the code does not work with numbers in the file. It only works for files with characters only. Sorry should have mentioned earlier, got numbers in some of my files too !!!