## AWK script: decrypt text uses frequency analysis

AWK script: decrypt text uses frequency analysis
# 1
11-26-2007
AWK script: decrypt text uses frequency analysis

Ez all!
I have a question how to decrypt text uses letter frequency analysis. I have code which count the letters, but what i need to do after that. Can anybody help me to write a code. VERY NEEDED! My code now:

#!/usr/bin/awk -f
BEGIN { FS="" }
{
for (i=1; i <= NF; i++) {
if (\$i != " ")
letter[tolower(\$i)]++
}
}
END {
j = 1
for (i in letter) {
ind[j] = i
j++
}
n = asort(ind)
for (i = 1; i <= n; i++)

printf "%s: %s\n", ind[i], letter[ind[i]]
}
 SerJel View Public Profile for SerJel Find all posts by SerJel
# 2
11-26-2007
how i understand i need to sort the letter[ind[i]] and then the most bigger will be "e". But how to do that?
 SerJel View Public Profile for SerJel Find all posts by SerJel
# 3
11-26-2007
Don't know if this is what you want, anyway:
 Klashxx View Public Profile for Klashxx Find all posts by Klashxx
# 4
11-27-2007
My code:
#!/usr/bin/awk -f

function swapa(arr,i,j, tmp) {
tmp=arr[i];
arr[i]=arr[j];
arr[j]=tmp;
}
function _qsort(arr,keys,i,j, k,i2,j2) {
if(j-i<1)
return

i2=i; j2=j;
# pivot, later algorithm depends on i here,
# so be careful if going to change it
k=arr[keys[i]];

while(i2<j2) {
# push i2 to the right until there is k greater element
while(i2<=j && arr[keys[i2]]<=k) i2++;
# push j2 to the left until there is k less/equal element
while(j2>=i && arr[keys[j2]]>k) j2--;

if(i2<j2)
swapa(keys, i2, j2);
}

# if i2>j then there were no elements greater than k
# this is special case where we assume k as greatest element
# and place it to the end of the list
if(i2>j) {
swapa(keys, i, j);
i2--; j2--;
}

# recurse for subarrays
_qsort(arr, keys, i, j2);
_qsort(arr, keys, i2, j);
}

function qsort(arr,keys, n,i,k) {
for(k in arr) {
keys[++i] = k
}
n=i;

_qsort(arr, keys, 1, n);

return n;
}

BEGIN { FS="" }
{

for (i=1; i <= NF; i++) {
if (\$i != " ")
letter[tolower(\$i)]++
}
}
#END {
# j = 1
# for (i in letter) {
# ind[j] = i
# j++
# }
# n = asort(ind)
# for (i = 1; i <= n; i++)
# printf "%s: %s\n", ind[i], letter[ind[i]]

#}
END {
j = 1
for (i in letter) {
ind[j] = i
j++}
n=qsort(letter,ind);
for(i=n; i>0; --i) {

print ind[i],letter[ind[i]];
}
}

END {
#to ="etaniosrlhdgcufm-pbyw.,v1:6kx932()-/8750qzj;][=4>+<@*'#"
to="#'*@<+>4=[];jzq0578/-)(239xk6:1v,.wybp-mfcugdhlrsoinate"
j = 1
for (i in letter) {
ind[j] = i
j++}
n=qsort(letter,ind);
for(i=1; i<=NF; i++) {
letter2[ind[i]] = substr(to, i, 1)
#print ind[i],letter[ind[i]];
}

{
for (i = 1; i<=NF; i++) {
char = substr(\$0, i, 1)
if (match(char, "[a-zA-Z]") != 0) {
printf("%c", letter2[char])
} else {
printf("%c", char)
}
}
printf("\n")
}}
But it doesnt work so how i need, it replace the letters wrong. Can anybody help?
 SerJel View Public Profile for SerJel Find all posts by SerJel
# 5
11-27-2007
The letters which have the most bigger frequency must be replace by "e" and so.
 SerJel View Public Profile for SerJel Find all posts by SerJel

## Encrypt and decrypt a password in shell script

Hi All, very good morning all. I am trying to connect to informatica repository by using shell script. I have written pmrep connect command in the script file. But i need to provide repository, domain ,username and password to connect. Username and password are hard coded in the script...

## Need someone to decrypt an encoded text

Hello everybody, i have a big issue, i have to decode a big text in base64 a lot of times but there are 2 problems: i am a noob with unix system and shell, and i have problems with openssl and i can't decode anything. can anyone decode for me that base64? need a powerful computer, i can give some...

## Calculating cumulative frequency using awk

Hi, I wanted to calculate cumulative frequency distribution of my data that involves several arithmetic calls. I did things in excel but its taking me forever. this is what I want to do: var1.txt contains n observations which I have to compute for frequency which is given by 1/n and subsequently...

## Determine the frequency of each number within a text file

I'd like to determine the frequency that each number occurs within a text file. I know how to do this for a single number, but not for a set or list of numbers. Here's what I have grep -o 01 file.txt | wc -l Also, it's important that the numbers are two digits instead of 1, meaning that...

## Text analysis

Hey Guys, Does anyone know how to count the separate amount of words in a text file? e.g the 5 and 20 Furthermore does anyone know how to convert whole numbers in decimals? Thanks

## Help with text analysis - UNIX

Hey Guys I recently posted yesterday about trying to count the amount of separate words that exists in a text file e.g. walle.txt. i want the output to give to give me a list of words with a number next indicating how many times its came up in the file e.g: cat 20 the 11 if 40 I'm...

## word frequency counter - awk solution?

Dear all, i need your help on this. There is a text file, i need to count word frequency for each word with frequency >40 in each line of file and output it into another file with columns like this: word1,word2,word3, ...wordn 0,0,1 1,2,0 3,2,0 etc -- each raw represents...

## Date and time range extraction via Awk or analysis script?

Hello does anyone know of an awk that will extract log file entries between a specific date and time range, eg: awk '/15\/Dec\/2010:16:10:00/, /15\/Dec\/2010:16:15:00/' access_log but one that works? Or a free command line log file analysis tool/script? I'd like to be able to view...

## text file analysis

Hello, I have a text file containin 4 lines which are repeated along the file, ie the file looks like this: 16:20:12.060769 blablabla 40 16:20:12.093199 blablabla 640 16:20:12.209003 blablabla 640 16:20:12.273179 blablabla 216 16:20:27.217444 blablabla 40 16:20:27.235410 blablabla 640...

## Encrypt and Decrypt script

Dear Experts, I am using one script name :volume.sh and its written in bash shell script. I just want to encrypt the script so that any one else cannot see it. please tell me the commands how to encrypt the script as well as to decrypt it. Regards, SHARY