|
|
|
|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Hi Guys,
I want to write a perl/shell script do parse the following file input file content NPA-NXX SC 2084549 45 2084552 45 2084563 2007 2084572 45 2084580 45 3278411 45 3278430 45 3278493 530 3278507 530 3278508 44 3278514 44 the output i require should contain first columns first three digits and then the count of numbers with that first three digits per SC wise NPA Count(NPA) SC 208 6 45 208 1 2007 327 2 530 327 2 44 Thanks and regards |
| Sponsored Links | ||
|
|
|
|||
|
Code:
sed 's/.... / /' file | sort | uniq -c The output puts the counts before the entries; you can pass that to another simple sed or awk script if you really require the count to be the second field. |
| Sponsored Links |
|
|
![]() |
| Bookmarks |
| Tags |
| count |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script to manipulate a message count for the same IP @ diff session | gobinath | Shell Programming and Scripting | 1 | 05-28-2008 04:13 PM |
| Number of lines in a file (perl script) | jisha | Shell Programming and Scripting | 5 | 05-20-2008 08:11 AM |
| Perl script to scan back lines | gholdbhurg | Shell Programming and Scripting | 3 | 03-18-2008 12:33 PM |
| How to Run a shell script from Perl script in Parent shell? | hifake | Shell Programming and Scripting | 16 | 08-28-2007 09:42 PM |
| How to count lines - ignoring blank lines and commented lines | kthatch | UNIX for Dummies Questions & Answers | 6 | 05-25-2007 02:21 AM |