Page 1 of 1

count words

PostPosted: Thu Jun 05, 2014 9:44 pm
by pulcinella
Hello

I write in this forum for if we can help me. I need to count the times that appear three chains of characters (dog, cat, snake) in the position 153 in several files (35 files for example) and obtain one output file. These chains not always can be in all the files (in the first one three chains can appear, in the second one also but probably in the third one only appear two chains). The files of entry have equal number of records. For example:


INPUT FILE 1
------------

xxxxxxxDOG xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxDOG xxxxxxx
xxxxxxxDOG xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxDOG xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx

INPUT FILE 2
------------

xxxxxxxDOG xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxDOG xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx

INPUT FILE 3
------------

xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxCAT xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx
xxxxxxxSNAKE xxxxxxx

I want obtain one output file with this structure

DOG SNAKE CAT
-------------
INPUT FILE 1: 4 4 4
INPUT FILE 2: 2 6 4
INPUT FILE 3: 0 7 5

Or this other

INPUT FILE 1: DOG(4) SNAKE(4) CAT(4)
INPUT FILE 2: DOG(2) SNAKE(6) CAT(4)
INPUT FILE 3: DOG(0) SNAKE(7) CAT(5)


Early graces