Sponsored Content
Full Discussion: Total Count using AWK
Top Forums Shell Programming and Scripting Total Count using AWK Post 302547509 by sraj142 on Tuesday 16th of August 2011 02:12:05 AM
Old 08-16-2011
Question Total Count using AWK

Hi Everybody,

I have the following example file...
Code:
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
199|TST-GURGAON|GURGAON|1
1|TST - MAIN LAB|DELHI|1
1|TST - MAIN LAB|DELHI|1
1|TST - MAIN LAB|DELHI|1
333|TST-PREET VIHAR|DELHI|1
333|TST-PREET VIHAR|DELHI|1
333|TST-PREET VIHAR|DELHI|1
333|TST-PREET VIHAR|DELHI|1
61B|PARNAMI X-RAY & CLINICAL LAB|DELHI|1
650|PUNJABI BAGH|DELHI|1
650|PUNJABI BAGH|DELHI|1
650|PUNJABI BAGH|DELHI|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
871|GREATER NOIDA C.C|GREATER NOIDA|1
897|NETAJI NAGAR C.C|DELHI|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1
VK1|NATIONAL DIAGNOSTICS|PATNA|1

I am looking for a AWK or PERL solution (A single line code is highly prefered) to produce the following...

Code:
199|TST-GURGAON|GURGAON|9
1|TST - MAIN LAB|DELHI|3
333|TST-PREET VIHAR|DELHI|4
61B|PARNAMI X-RAY & CLINICAL LAB|DELHI|1
650|PUNJABI BAGH|DELHI|3
871|GREATER NOIDA C.C|GREATER NOIDA|8
897|NETAJI NAGAR C.C|DELHI|1
VK1|NATIONAL DIAGNOSTICS|PATNA|8

Basically the I am looking to print the total count based on the first field.

Could any body from you may give me a hand please ?

Regards - Sraj142

Last edited by Scott; 08-16-2011 at 05:48 AM.. Reason: Added code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

total count of inodes in a mount

is there Any command to get total count and number of free inodes on a mount. please help (5 Replies)
Discussion started by: pharos467
5 Replies

2. Shell Programming and Scripting

Bogus Total count

I have a shell script that I am pulling different zip file packages and totaling how many of each type of package is in the directory. I get a bogus total count of one in the middle of my output file (highlighted in RED) and not sure why, also would like to get a grand total of all files but not... (2 Replies)
Discussion started by: freddie999
2 Replies

3. Shell Programming and Scripting

total count of a word in the files

Hi Friends, Need help regarding counting the word "friend" in files test1.txt and test2.txt. ( there is no gap/space between word ) cat test1.txt himynameisrajandiamfriendofrajeshfriend wouldyouliketobemyfriend. cat test2.txt himynameisdostandiamfriendofdostfriend... (2 Replies)
Discussion started by: forroughuse
2 Replies

4. Shell Programming and Scripting

Why sum of recs in awk don't match total rec count?

I'm using awk to determine if a field starting in position 604 for length of 10 is not equal to ALL spaces. It's searching several files which are in the current directory. The below awk indicates that there are 84 records on all files where this field IS NOT equal to ALL spaces ( there are 10... (2 Replies)
Discussion started by: mjf
2 Replies

5. Shell Programming and Scripting

Finding total count of a word.

i want to find the no:of occurrences of a word in a file cat 1.txt unix script unix script unix script unix script unix script unix script unix script unix script unix unix script unix script unix script now i want to find , how many times 'unix' was occurred please help me thanks... (6 Replies)
Discussion started by: mahesh1987
6 Replies

6. UNIX for Dummies Questions & Answers

In ls -l remove total count

Hi All, When i give ls -ltr i get 'total 10' like this along with files long listing. is there any option in ls command to remove this line or do we need use head -1 command only. $ls -ltr total 45 -rw-r--r-- 1 abc g1 0 Jul 17 07:20 0 -rw-r--r-- 1 abc g1 744 May 9 12:10 a -rw-r--r--... (1 Reply)
Discussion started by: HemaV
1 Replies

7. UNIX for Dummies Questions & Answers

Count total image in directory

Dear all, I have a directory consisted of files in .jpg, .jpeg etc..all of them are image 20140411030143_62811159403_92886.jpg 5/11/2014 15:01 197K 20140415024737_62811618747_116460.jpg 4/15/2014 14:47 17K 20140415031003_62811618747_109192.jpg 4/17/2014 15:10 17K... (4 Replies)
Discussion started by: radius
4 Replies

8. Shell Programming and Scripting

Total count in each category for given file list

I have list of file names in filename.txt below is file format >>File1 _________________________ 01~12345~Y~YES~aaaaa~can 02~23456~N~NO~bbbbb~can . . . 99~23__________________________ Need to find total count from each file depending on specific string and add them to have total count... (17 Replies)
Discussion started by: santoshdrkr
17 Replies

9. Shell Programming and Scripting

Count total duplicates

Hi all, I have found another post threads talking about count duplicate lines, but I am interested in obtain the total number of duplicates. For example: #file.txt a1 a2 a1 a3 a1 a2 a4 a5 #out 3 (lines are duplicates) Thank you! (12 Replies)
Discussion started by: mikloz
12 Replies
IMAGESETTILE(3) 							 1							   IMAGESETTILE(3)

imagesettile - Set the tile image for filling

SYNOPSIS
bool imagesettile (resource $image, resource $tile) DESCRIPTION
imagesettile(3) sets the tile image to be used by all region filling functions (such as imagefill(3) and imagefilledpolygon(3)) when fill- ing with the special color IMG_COLOR_TILED. A tile is an image used to fill an area with a repeated pattern. Any GD image can be used as a tile, and by setting the transparent color index of the tile image with imagecolortransparent(3), a tile allows certain parts of the underlying area to shine through can be created. Note You need not take special action when you are finished with a tile, but if you destroy the tile image, you must not use the IMG_COLOR_TILED color until you have set a new tile image! PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). o $tile - The image resource to be used as a tile. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 imagesettile(3) example <?php // Load an external image $zend = imagecreatefromgif('./zend.gif'); // Create a 200x200 image $im = imagecreatetruecolor(200, 200); // Set the tile imagesettile($im, $zend); // Make the image repeat imagefilledrectangle($im, 0, 0, 199, 199, IMG_COLOR_TILED); // Output image to the browser header('Content-Type: image/png'); imagepng($im); imagedestroy($im); imagedestroy($zend); ?> The above example will output something similar to:[NOT DISPLAYABLE MEDIA]Output of example : imagesettile() PHP Documentation Group IMAGESETTILE(3)
All times are GMT -4. The time now is 11:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy