shell script required

Hi,
iam presenting the input text file format.Of this i need the character count of the number of characters present in each file.The attached file is a combination of 3 text file.each text file starts at record 1 - 34, then the next tetx file starts. What i need is the character count of each text file in the main text file.the 3 text file is in a main text file called 71018158.txt.

The first 2 lines of each text file is not required for character count.
I tried the following cmd to remove those 2 line

grep -v "^01" *.txt | wc -m
grep -v "^02" *.txt | wc -m
and i also don't need the " ^ " present in the text file for the determination of the character count.
Hope u understand the point.

Regards
Sethunath

01^V1.0^EXPORTED^2470717800001001001^71018158^00000001^C0^4686019C^AJ82^A457^^n:\indata\20070628\71018158^71018158.001^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^01^50^01
02^^^71018158^01^01^^^2470717^800001^001^N^^^
03^07611983-01^SAME^^^SAME^^^^^^^^
04^^^^^4616 ^^DE95316^^^95316^^^1^1^Y^Y
05^2^^^^^^^^
06^29633^^^^^^^^^^1
07^061807^061807^11^^90801^^^^^1^ 31000^1^^^^^^00C323001
08^^^^^^^^^^^^^^^^^^
09^^^^^^^^^^^^^^^^^^
10^^^^^^^^^^^^^^^^^^
11^^^^^^^^^^^^^^^^^^
12^^^^^^^^^^^^^^^^^
13^^^^^^^^^^^^^^^^^
14^^^^^^^^^^^^^^^^^
15^^^^^^^^^^^^^^^^^
16^^^^^^^^^^^^^^^^^
17^^^^^^^^^^^^^^^^^
18^^^^^^^^^^^^^^^^^
19^^^^^^^^^^^^^^^^^
20^^^^^^^^^^^^^^^^^
21^^^^^^^^^^^^^^^^^
22^^^^^^^^^^^^^^^^^
23^^^^^^^^^^^^^^^^^
24^^^^^^^^^^^^^^^^^
25^^^^^^^^^^^^^^^^^
26^^^^^^^^^^^^^^^^^
27^^^^^^^^^^^^^^^^^
28^^^^^^^^^^^^^^^^^
29^^^^^^^^^^^^^^^^^
30^^^^^^^^^^^^^^^^^
31^^ 31000
32^Y^^STEWART^^^MD^-0388035^SWART MD^3340 ROAD, D-2^^MO95350^^CA^95350^^^^^^^MD^220 F^^MO95350^MODESTO^CA^95350^^^2095795628^
01232001^
33^^^^^^^^^^071700164-00
34^^^1609987510^1912090622^^1912090622^^2^
01^V1.0^EXPORTED^2470717800002001001^71018158^00000002^C0^4686019C^AJ82^A457^^n:\indata\20070628\71018158^71018158.002^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^02^50^01
02^^^71018158^01^01^^^2470717^800002^001^N^^^
03^7398347-01^SAME^^^SAME^^^^^^^^
04^^MATTHEW^^^3901 RD^^CE95307^^CA^95307^^11011979^1^1^Y^Y
05^2^^^^^^^^
06^30002^^^^^^^^^^1
07^061807^061807^11^^90807^^^^^1^ 20600^1^^^^^^00C323001
08^^^^^^^^^^^^^^^^^^
09^^^^^^^^^^^^^^^^^^
10^^^^^^^^^^^^^^^^^^
11^^^^^^^^^^^^^^^^^^
12^^^^^^^^^^^^^^^^^
13^^^^^^^^^^^^^^^^^
14^^^^^^^^^^^^^^^^^
15^^^^^^^^^^^^^^^^^
16^^^^^^^^^^^^^^^^^
17^^^^^^^^^^^^^^^^^
18^^^^^^^^^^^^^^^^^
19^^^^^^^^^^^^^^^^^
20^^^^^^^^^^^^^^^^^
21^^^^^^^^^^^^^^^^^
22^^^^^^^^^^^^^^^^^
23^^^^^^^^^^^^^^^^^
24^^^^^^^^^^^^^^^^^
25^^^^^^^^^^^^^^^^^
26^^^^^^^^^^^^^^^^^
27^^^^^^^^^^^^^^^^^
28^^^^^^^^^^^^^^^^^
29^^^^^^^^^^^^^^^^^
30^^^^^^^^^^^^^^^^^
31^^ 20600
32^Y^^STEWART^^^MD^^QUISLING, MD^3340 ROAD, D-2^^MO95350^^CA^95350^^^QUISLING^^^^MD^220 SAVE., #F^^MO95350^^CA^95350^^^209579
5628^05152006^
33^^^^^^^^^^061300348
34^^^1609987510^1912090622^^1912090622^^2^
01^V1.0^EXPORTED^2470717800003001001^71018158^00000003^C0^4686019C^AJ72^A457^NEWHCFA^n:\indata\20070628\71018158^71018158.003
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^03^50^01
02^^^71018158^01^01^^^2470717^800003^001^N^^^
03^WBW902A68176^SAME^^^SAME^^^^^^^^
04^^JOSEPH^^^907 HELMS ^^MO95350^^CA^95350^^10221946^1^1^^Y
05^2^^^^^^^^
06^29633^^^^^^^^^^1
07^061807^061807^11^^90807^^^^^1^ 20600^1^^^^^^00C323001
08^^^^^^^^^^^^^^^^^^
09^^^^^^^^^^^^^^^^^^
10^^^^^^^^^^^^^^^^^^
11^^^^^^^^^^^^^^^^^^
12^^^^^^^^^^^^^^^^^
13^^^^^^^^^^^^^^^^^
14^^^^^^^^^^^^^^^^^
15^^^^^^^^^^^^^^^^^
16^^^^^^^^^^^^^^^^^
17^^^^^^^^^^^^^^^^^
18^^^^^^^^^^^^^^^^^
19^^^^^^^^^^^^^^^^^
20^^^^^^^^^^^^^^^^^
21^^^^^^^^^^^^^^^^^
22^^^^^^^^^^^^^^^^^
23^^^^^^^^^^^^^^^^^
24^^^^^^^^^^^^^^^^^
25^^^^^^^^^^^^^^^^^
26^^^^^^^^^^^^^^^^^
27^^^^^^^^^^^^^^^^^
28^^^^^^^^^^^^^^^^^
29^^^^^^^^^^^^^^^^^
30^^^^^^^^^^^^^^^^^
31^^ 20600
32^Y^QUISLING^^^^MD^0388035^STEWART^3340 ROAD, D-2^^MO95350^^CA^95350^^^QUISLING^STEWART^^^MD^220 STANDAVE., #F^^^MODESTO^CA^
95350^^^2095795628^05072007^
33^^^^^^^^^^071240677
34^^^1609987510^1912090622^^1912090622^^2^

I'm sure there's a more elegant way to do this, but a rapid solution could be:

sed "/^01/d; /^02/d; s/\^//g; s/^..//" 71018158.txt | split -32 - 71018158.part.
wc -m 71018158.part.*
rm 71018158.part.*

-----------------------------------------------------------

./script.sh
264 71018158.part.aa
284 71018158.part.ab
301 71018158.part.ac
849 total

I suppose that you don't wanna count characters belonging to the number of records at the beginning of each line (01, 02, 03...), otherwise you have to remove "s/^..//".

I also assume that the rows in your input file that aren't numbered (e.g. the line after the 32nd row in the first block of text) is actually a single long line (the continuation of 32nd row). If this isn't a mistake you've done with copy/paste, my script won't work :slight_smile:

Bye