09-30-2008
hi
can any one help me for little bit change in my first prob
i have file which hav following entries
1501,AAA,2.00
1525,AAA,2.00
1501,AAA,2.00
1525,AAA,2.00
1501,AAA,3.00
1525,AAA,3.00
1525,AAA,3.00
1501,AAA,3.00
1501,AAA,3.00
i want to have a o/p coloum wise
like
col1,col2,sum,count
1501,AAA,13 ,5
1525,AAA,10,4
here 13 comes as a sum of last colum value corrosponds to 1501
similarly 10 comes as a sum of last colum value corrosponds to 1525
as per sol given my era
awk -F "," '{ sum[$1 "," $2] += $3 } END { for (k in sum) print k "," sum[k] }' file
it is working fine but if i have to find count too then what need to change in this command
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a m X n matrix written out to file, say like this:
1,2,3,4,5,6
2,6,3,10,34,67
1,45,6,7,8,8
I want to calculate the column averages in the MINIMUM amount of code or processing possible. I would have liked to use my favorite tool, "AWK" but since it processes rowwise, getting the... (5 Replies)
Discussion started by: Abhishek Ghose
5 Replies
2. Shell Programming and Scripting
Shell script for the below operation :
File "A" contains :
SEQ++1'
MOA+9:000,00:ABC'
RFF+AIK:000000007'
FII+PH+0170++AA'
NAD+PL+++XXXXXXXXXXX XXXXXXX XX++XXX XXXX XXXX X.X. XXXXXXXXX+++NL'
SEQ++2'
MOA+9:389,47:ABC'
RFF+AIK:02110300000008'
FII+PH+0PSTBNL2A:25:5+BB'... (5 Replies)
Discussion started by: navojit dutta
5 Replies
3. Solaris
Hi,
I have two files. Want to make an addition of the fifth column of from both the files and redirect it to a third file.
Both files have same records except fifth field and same record should be inserted into new file having fifth field as addition of fifth fields of both files.
for... (2 Replies)
Discussion started by: sanjay1979
2 Replies
4. Shell Programming and Scripting
Hello All ,
I have a problem with summing of column by group
Input File -
COL_1,COL_2,COL_3,COL_4,COL_5,COL_6,COL_7,COL_8,COL_9,COL_10,COL_11
3010,21,1923D ,6,0,0.26,0,0.26,-0.26,1,200807
3010,21,192BI ,6,24558.97,1943.94,0,1943.94,22615.03,1,200807
3010,21,192BI... (8 Replies)
Discussion started by: jambesh
8 Replies
5. Shell Programming and Scripting
i have a file which has a column that is unique
i am intending to serach it and if it is there to remove the row.
the file looks like
ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT
15 ,rig ,34 ,56 ,87 ,177 ,59 % ,PASS
23 ,wel ,45 ,76 ,56 ,177 ,59 % ... (0 Replies)
Discussion started by: gotam
0 Replies
6. Shell Programming and Scripting
Scottn, m really sorry but i have not got my answer yet.
my concern is how to delete the row !!!
i have a file which has a column that is unique
i am intending to serach it and if it is there to remove the row.
the file looks like
ROLLNO,NAME ,SUB1,SUB2,SUB3,TOTAL,PERCENTAGE,RESULT... (9 Replies)
Discussion started by: gotam
9 Replies
7. Shell Programming and Scripting
Hi I have pasted sample data as below:- in data.txt
Please suggest any way out: as the 3rd field is
cat data.txt
22:37:34 STARTING abc
22:37:40 FAILURE sadn
00:06:42 STARTING asd
00:06:51 FAILURE ad
02:06:38 STARTING acs
02:06:46 FAILURE cz
04:06:35 STARTING xzc... (1 Reply)
Discussion started by: Gaurav198
1 Replies
8. Shell Programming and Scripting
Hi All,
I have a file with below content
01/22/2014,23:43:00,1742.8,
01/22/2014,23:43:00,1742.8,
01/22/2014,23:44:00,1749.06666666667,
01/25/2014,23:45:00,2046.45,
01/25/2014,23:43:00,1742.8,
01/25/2014,23:44:00,1749.06666666667,
01/25/2014,23:45:00,2046.45,
01/25/2014,23:43:00,1742.8,... (4 Replies)
Discussion started by: villain41
4 Replies
9. Shell Programming and Scripting
Hello,
I have a comma seperate metadata as follows:
CITY ,COUNTY,STATE,COUNTRY
NEW_YORK,NYC ,NY ,USA
NEWARK ,ESSEX ,NJ ,USA
CHICAGO ,COOK ,IL ,USA
SEATTLE ,MINER ,WA ,USA
In my process, I get two key values ie
CITY NAME (can be one of the... (7 Replies)
Discussion started by: calredd
7 Replies
10. Shell Programming and Scripting
My below code works fine if none of the columns has pipe as its content in it, If it has the pipe in any of the content then the value moves to the next column.
I wanted my code to work fine even if the column has pipe in it apart from the delimiter.
NOTE : If there is a pipe in the content... (6 Replies)
Discussion started by: nikhil jain
6 Replies
LEARN ABOUT REDHAT
autosplit
AutoSplit(3pm) Perl Programmers Reference Guide AutoSplit(3pm)
NAME
AutoSplit - split a package for autoloading
SYNOPSIS
autosplit($file, $dir, $keep, $check, $modtime);
autosplit_lib_modules(@modules);
DESCRIPTION
This function will split up your program into files that the AutoLoader module can handle. It is used by both the standard perl libraries
and by the MakeMaker utility, to automatically configure libraries for autoloading.
The "autosplit" interface splits the specified file into a hierarchy rooted at the directory $dir. It creates directories as needed to
reflect class hierarchy, and creates the file autosplit.ix. This file acts as both forward declaration of all package routines, and as
timestamp for the last update of the hierarchy.
The remaining three arguments to "autosplit" govern other options to the autosplitter.
$keep
If the third argument, $keep, is false, then any pre-existing "*.al" files in the autoload directory are removed if they are no longer
part of the module (obsoleted functions). $keep defaults to 0.
$check
The fourth argument, $check, instructs "autosplit" to check the module currently being split to ensure that it includes a "use" specifi-
cation for the AutoLoader module, and skips the module if AutoLoader is not detected. $check defaults to 1.
$modtime
Lastly, the $modtime argument specifies that "autosplit" is to check the modification time of the module against that of the
"autosplit.ix" file, and only split the module if it is newer. $modtime defaults to 1.
Typical use of AutoSplit in the perl MakeMaker utility is via the command-line with:
perl -e 'use AutoSplit; autosplit($ARGV[0], $ARGV[1], 0, 1, 1)'
Defined as a Make macro, it is invoked with file and directory arguments; "autosplit" will split the specified file into the specified
directory and delete obsolete ".al" files, after checking first that the module does use the AutoLoader, and ensuring that the module is
not already currently split in its current form (the modtime test).
The "autosplit_lib_modules" form is used in the building of perl. It takes as input a list of files (modules) that are assumed to reside in
a directory lib relative to the current directory. Each file is sent to the autosplitter one at a time, to be split into the directory
lib/auto.
In both usages of the autosplitter, only subroutines defined following the perl __END__ token are split out into separate files. Some rou-
tines may be placed prior to this marker to force their immediate loading and parsing.
Multiple packages
As of version 1.01 of the AutoSplit module it is possible to have multiple packages within a single file. Both of the following cases are
supported:
package NAME;
__END__
sub AAA { ... }
package NAME::option1;
sub BBB { ... }
package NAME::option2;
sub BBB { ... }
package NAME;
__END__
sub AAA { ... }
sub NAME::option1::BBB { ... }
sub NAME::option2::BBB { ... }
DIAGNOSTICS
"AutoSplit" will inform the user if it is necessary to create the top-level directory specified in the invocation. It is preferred that the
script or installation process that invokes "AutoSplit" have created the full directory path ahead of time. This warning may indicate that
the module is being split into an incorrect path.
"AutoSplit" will warn the user of all subroutines whose name causes potential file naming conflicts on machines with drastically limited (8
characters or less) file name length. Since the subroutine name is used as the file name, these warnings can aid in portability to such
systems.
Warnings are issued and the file skipped if "AutoSplit" cannot locate either the __END__ marker or a "package Name;"-style specification.
"AutoSplit" will also emit general diagnostics for inability to create directories or files.
perl v5.8.0 2002-06-01 AutoSplit(3pm)