Sponsored Content
Top Forums Shell Programming and Scripting Help with sum total number of record and total number of record problem asking Post 302582923 by balajesuri on Monday 19th of December 2011 03:34:06 AM
Old 12-19-2011
As per desired output.. with sum sorted in descending order.
Code:
perl -ane '$x{$F[0]}+=$F[1];$y{$F[0]}++; END{%x=reverse %x;print "$x{$_} $_ $y{$x{$_}}\n" for(reverse sort{$a<=>$b} keys %x)}' inputfile


Last edited by balajesuri; 12-19-2011 at 05:24 AM..
This User Gave Thanks to balajesuri For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

total number of lines

Hi have following file |abcd 2|abcd |sdfh |sdfj I want to find total number of files haivng nothing in feild 1 using awk will command awk -F "|" '( $1=="") {print NR}' test_awk will work??? (4 Replies)
Discussion started by: mahabunta
4 Replies

2. Shell Programming and Scripting

total number of lines in a file

Hi , How about find the total number of lines in a file ? How can i do that with the "grep" command ? (9 Replies)
Discussion started by: Raynon
9 Replies

3. Shell Programming and Scripting

csv file - adding total to a trailer record

Hi, I have a script which creates and modifies a csv file. I have managed to do everything I need to do apart from 1 thing. I need to append a trailer record to the file. I need this line to hold the total of an entire column of the csv file (skipping the 1st line which is a header). Can... (2 Replies)
Discussion started by: mcclunyboy
2 Replies

4. Shell Programming and Scripting

Help with calculate total sum of same data problem

Long list of input file: AGDRE1 0.1005449050 AGDRE1 2.1005443435 AGDRE1 1.2005449050 AGDRE1 5.1005487870 AASFV3 50.456304789 AASFV3 2.3659706549 AASFV3 6.3489807860 AASFV3 3.0089890148 RTRTRS 5.6546403546 . . Desired output file: AGDRE1 8.5021829410 AASFV3 62.180245240... (2 Replies)
Discussion started by: perl_beginner
2 Replies

5. HP-UX

Total number of files in a FS

Hello people, On HP-UX B.11.11 U 9000/800 How can I have in aprox. the total number of files in a specific FS? Is the number of used inodes a rough estimation of my total number of files? Server1 /Data:df -i . /Data (/dev/vg_Data/lvol1 ) : 18292960 total i-nodes 15800945 free... (3 Replies)
Discussion started by: drbiloukos
3 Replies

6. Linux

get total number of packages installed?

Hi, Which command would tell me of how many total number packages installed on my Redhat? Thank you, Lam (2 Replies)
Discussion started by: lamoul
2 Replies

7. Shell Programming and Scripting

Problem to print out record got smallest number in specific column

Hi, Anybody know how to print out the record that shown smallest number among column 3 and column 4 Case 1 Input : 37170 37196 77 51 37174 37195 73 52 37174 37194 73 53 Case 1 Output : 37170 37196 77 51 Case 2 Input : 469613 469660 73 ... (4 Replies)
Discussion started by: cpp_beginner
4 Replies

8. Shell Programming and Scripting

Problem facing to compare different column and print out record with smallest number

Hi, Input file 1 : 37170 37196 77 51 37174 37195 73 52 37174 37194 73 53 Desired Output file 1 : 37170 37196 77 51 Input file 2 : 37174 37195 73 0 37170 37196 77 0 Desired Output file 2 : 37174 37195 73 0 (1 Reply)
Discussion started by: cpp_beginner
1 Replies

9. Shell Programming and Scripting

Help with calculate the total sum of record in column one

Input file: 101M 10M10D20M1I70M 10M10D39M4I48M 10M10D91M 10M10I13M2I7M1I58M 10M10I15M1D66M Output file: 101M 101 0 0 10M10D20M1I70M 100 1 10 10M10D39M4I48M 97 4 10 10M10D91M 101 0 10 10M10I13M2I7M1I58M 88 13 0 10M10I15M1D66M 91 10 1 I'm interested to count how many total of... (6 Replies)
Discussion started by: perl_beginner
6 Replies

10. Shell Programming and Scripting

Total record count of all the file present in a directory

Hi All , We need one help on the below requirement.We have multiple pipe delimited .txt file(around 100 .txt files) present on one directory.We need the total record count of all the files present in that directory without header.File format as below : ... (8 Replies)
Discussion started by: STCET22
8 Replies
SORT-DCTRL(1)						       Debian user's manual						     SORT-DCTRL(1)

NAME
sort-dctrl - sort Debian control files SYNOPSIS
sort-dctrl [options] [ file ... ] sort-dctrl --copying | --help | --version | -ChV DESCRIPTION
The sort-dctrl program sorts Debian control files according to specified criteria. A Debian control (dctrl) file is a semistructured single-table database stored in a machine-parseable text file. Such a database consists of a set of records; each record is a mapping from field names to field content. Textually, records are separated by empty lines, while each field is encoded as one or more nonempty lines inside a record. A field starts with its name, followed by a colon, followed by the field content. The colon must reside on the first line of the field, and the first line must start with no whitespace. Subsequent lines, in contrast, always start with linear whitespace (one or more space or tab characters). The sort-dctrl program recognizes two field types: string fields and version fields. Version fields act also as numeric fields. String fields are compared according to strict lexicographical octet-by-octet comparison, after ignoring any initial whitespace after the colon. Version fields are parsed and compared as Debian version numbers. When comparing version numbers, if a field content does not in fact con- form to the version number syntax, it compares less than any field content that does conform, and equal to any other nonconforming field content. The sort-dctrl program assumes all fields are string fields unless told otherwise. You can specify arbitrary number of keys for sorting, using the -k option. The keys are interpreted in a descending order of priority: the first key specified is primary, the second key specified is secondary, and so on. If two records compare equal under the primary key, then they are compared under the secondary key, and so on. If no keys are specified, a default key is assumed (the "Package" field with no mod- ifiers). OPTIONS
-k keyspec, --key-spec=keyspec Specify one or more keys for sorting. You may specify this option any number of times. The keyspec argument consists of a comma- separated list of key specifications. Each key specification consists of the name of the field that serves as the key, optionally followed by a colon and key modifiers. The following key modifiers are supported: r Invert the comparison for this key, reversing the sorting order. v Treat this field as a version number field. n Treat this field as numeric, which currently is synonymous with v. -q, --quiet, --silent Output nothing to the standard output stream. Instead, exit immediately after finding the first match. -l level, --errorlevel=level Set log level to level. level is one of fatal, important, informational and debug, but the last may not be available, depending on the compile-time options. These categories are given here in order; every message that is emitted when fatal is in effect, will be emitted in the important error level, and so on. The default is important. -V, --version Print out version information. -C, --copying Print out the copyright license. This produces much output; be sure to redirect or pipe it somewhere (such as your favourite pager). -h, --help Print out a help summary. EXAMPLES
Here are some sample invocations of the program: sort-dctrl /var/lib/dpkg/available Output the dpkg available file sorted by the package name. sort-dctrl -k Version:v /var/lib/dpkg/available Output the dpkg available file sorted in ascending order of version numbers. sort-dctrl -k Version:vr /var/lib/dpkg/available Output the dpkg available file sorted in descending order of version numbers. sort-dctrl -k Package,Version:v /var/lib/dpkg/available Output the dpkg available file sorted primarily in ascending order of package names and secondarily in descending order of version numbers. sort-dctrl -k Installed-Size:n,Size:nr /var/lib/dpkg/available Output the dpkg available file sorted primarily in ascending order of installation sizes and secondarily in descending order of package sizes. AUTHOR
The program and this manual page were written by Antti-Juhani Kaijanaho <ajk@debian.org>. SEE ALSO
Debian Policy Manual. Published as the Debian package debian-policy. Also available in the Debian website. grep-dctrl(1) Debian Project 2005-06-08 SORT-DCTRL(1)
All times are GMT -4. The time now is 09:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy