![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Column sum group by uniq records | Nayanajith | Shell Programming and Scripting | 17 | 05-20-2009 09:57 AM |
| To find the count of records from tables present inside a file. | navojit dutta | Shell Programming and Scripting | 1 | 08-29-2007 11:04 AM |
| Count No of Records in File without counting Header and Trailer Records | guiguy | Shell Programming and Scripting | 2 | 06-07-2007 12:15 PM |
| Help comparing 2 files to find deleted records | eja | UNIX for Dummies Questions & Answers | 2 | 04-03-2007 08:53 AM |
| How to find All Primary and Secondary Group ID's for a user | sanjay92 | UNIX for Dummies Questions & Answers | 2 | 03-27-2002 02:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
find and group records in a file
Hi,
I have this file which has 3 columns, District , stores and unit. What I want is all rows belonging to one district to be created separately under each district, the districts may vary every day , the source file may have 3 districts today and may have 160 tomorrow, so what I need is a script that puts all district rows in one file and so on , do you have any ideas ? Attached is the sample of what I am asking for Source File District Store UnitSales D1 ST101 4 D1 ST102 2 D1 ST103 3 D2 ST104 45 D2 ST105 6 D2 ST106 7 D1 ST107 8 D1 ST108 89 D2 ST109 8 D3 ST111 0 D3 ST101 7 D1 file D1 ST101 4 D1 ST102 2 D1 ST103 3 D1 ST107 8 D1 ST108 89 D2 file D2 ST104 45 D2 ST105 6 D2 ST106 7 D2 ST109 8 D3 file D3 ST111 0 D3 ST101 7 Thanks, very much |
|
||||
|
How Can I Aggregate A Field In A File
I Have a file
34EMEA|VODAFONE ES|5484|CPN|04/01/07|1|300 34LA|VODAFONE ES|5484|CPN|04/01/07|1|300 how can i aggregate it to 34EMEA|VODAFONE ES|5484|CPN|04/01/07|1|600 awk -F"|" '{ sum[$4] += $7 } END { for (name in sum) print name, sum[name] }' data_file this aggregarates if column 4 is similar. but if columns 2 to 5 are similare i want to aggregate. so when i tried awk -F"|" '{ sum[$2]sum[$3]sum[4] += $7 } END { for (name in sum) print name, sum[name] }' data_file it is not working. can u please help. Many thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|