I have some files as shown below
GLL ALM 654-656 654 656
SEM LYG 655-657 655 657
SEM LYG 655-657 655 657
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
ALM LEG 656-658 656 658
LEG LEG 658-660 658 660
LEG LEG 658-660 658 660
The value of GLL is 654. The value of ALM is 656. In the same way, 4th column represents the values of first column. 5th column represents the values of second column.
I tried the following program to count the occurrences of each number in the fourth and fifth column.
for i in folder1/*.pdb;
do
awk '
BEGIN {
path=sprintf("%s", "/home/arch/Desktop/folder2/")
}
!s[1":"$4":"$5]++{sU[$4]++;tot++}
!s[2":"$4":"$5]++{sU[$5]++;tot++}
END {
sub(/.*\//,"",FILENAME)
for (x in sU)
print x, sU[x], sU[$1] > path FILENAME;
}' $i;
done
The above program prints as follows
660 1
654 1
655 1
656 2
657 1
658 2
Desired Output:-
660 LEG 1
654 GLL 1
655 SEM 1
656 ALM 2
657 LYG 1
658 LEG 2
your suggestions would be appreciated!!