The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell Script Required? Pls. help me ntgobinath Shell Programming and Scripting 22 05-29-2008 07:09 AM
Shell Script Required ntgobinath Shell Programming and Scripting 3 05-06-2008 01:04 PM
Shell Script Required! vats Shell Programming and Scripting 3 08-28-2007 02:29 AM
shell script required sethunath Shell Programming and Scripting 4 07-06-2007 03:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2007
sethunath sethunath is offline
Registered User
  
 

Join Date: Jun 2007
Location: india
Posts: 5
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\710 18158^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\710 18158^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\20070 628\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^
  #2 (permalink)  
Old 07-07-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
I'm sure there's a more elegant way to do this, but a rapid solution could be:

Code:
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

Bye
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0