Sponsored Content
Top Forums Shell Programming and Scripting Issue on Suming up the values in awk Post 302323262 by devtakh on Saturday 6th of June 2009 04:34:44 AM
Old 06-06-2009
Code:
sort -k2,2 filename| awk 'NR==1{ord=$3;del=$4;s=$2;print $0 > s ;getline}
$2 !~ s {print "--------" > s;print "total",ord,del > s ;s=$2;ord=0;del=0}
$2 ~ s {ord+=$3;del+=$4;print $0 > s ;s=$2;next}END{print "--------" > s;print "total",ord,del > s}'


-Devaraj Takhellambam
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

2. Shell Programming and Scripting

AWK: read values from file1; search for values in file2

I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: 333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the... (2 Replies)
Discussion started by: Bubnoff
2 Replies

3. UNIX for Dummies Questions & Answers

Issue with use of Configuration file instead of hardcoded values inside the script

Hi, My code works perfectly fine. But, $my $min_to_add = 1 * 1 * 60; and my $hr_to_sub = 1 * 1 * 86400; i may need to change the values in future. so am keeping them in a separate configuration file like MIN = 1 * 1 * 60 HR = 24 * 60 * 60 in the script, i use a package use et_config... (3 Replies)
Discussion started by: irudayaraj
3 Replies

4. Shell Programming and Scripting

error in shell script while returning values-- urgent issue plz help.

Hi, I have initailized a varaible EBID as typeset Long EBID=0 i am calculating value of EBID using certian formula as below: (( CURR_EBID= ($BANDINDEX << 27) | ($CURR_FREQ << 16) | ($CURR_CELLID << 4) | $CURR_SECTOR_VALUE )) return $CURR_EBID The output is as below: + (( CURR_EBID=... (6 Replies)
Discussion started by: kasanur
6 Replies

5. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

6. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

7. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

8. Shell Programming and Scripting

Issue using awk to print min values for unique ids

I am using the following script to search for and print minimum values for each individual Fields (3-14) for each unique id (Field 1). But when the field contains a "-99.99" ( I am ignoring "-99.99") and when the minimum value is the first line of a new id (Field 1), the output does not print Field... (13 Replies)
Discussion started by: ncwxpanther
13 Replies
TCTMGR(1)							   Tokyo Cabinet							 TCTMGR(1)

NAME
tctmgr - the command line utility of the table database API DESCRIPTION
The command `tctmgr' is a utility for test and debugging of the table database API and its applications. `path' specifies the path of a database file. `bnum' specifies the number of buckets. `apow' specifies the power of the alignment. `fpow' specifies the power of the free block pool. `pkey' specifies the primary key of a record. `cols' specifies the names and the values of a record alternately. `name' specifies the name of a column. `op' specifies an operator. `expr' specifies the condition expression. `file' specifies the input file. tctmgr create [-tl] [-td|-tb|-tt|-tx] path [bnum [apow [fpow]]] Create a database file. tctmgr inform [-nl|-nb] path Print miscellaneous information to the standard output. tctmgr put [-nl|-nb] [-sx] [-dk|-dc|-dai|-dad] path pkey [cols ...] Store a record. tctmgr out [-nl|-nb] [-sx] path pkey Remove a record. tctmgr get [-nl|-nb] [-sx] [-px] [-pz] path pkey Print the value of a record. tctmgr list [-nl|-nb] [-m num] [-pv] [-px] [-fm str] path Print the primary keys of all records, separated by line feeds. tctmgr search [-nl|-nb] [-ord name type] [-m num] [-sk num] [-kw] [-pv] [-px] [-ph] [-bt num] [-rm] [-ms type] path [name op expr ...] Print records matching conditions, separated by line feeds. tctmgr optimize [-tl] [-td|-tb|-tt|-tx] [-tz] [-nl|-nb] [-df] path [bnum [apow [fpow]]] Optimize a database file. tctmgr setindex [-nl|-nb] [-it type] path name Set the index of a column. tctmgr importtsv [-nl|-nb] [-sc] path [file] Store records of TSV in each line of a file. tctmgr version Print the version information of Tokyo Cabinet. Options feature the following. -tl : enable the option `TDBTLARGE'. -td : enable the option `TDBTDEFLATE'. -tb : enable the option `TDBTBZIP'. -tt : enable the option `TDBTTCBS'. -tx : enable the option `TDBTEXCODEC'. -nl : enable the option `TDBNOLCK'. -nb : enable the option `TDBLCKNB'. -sx : the input data is evaluated as a hexadecimal data string. -dk : use the function `tctdbputkeep' instead of `tctdbput'. -dc : use the function `tctdbputcat' instead of `tctdbput'. -dai : use the function `tctdbaddint' instead of `tctdbput'. -dad : use the function `tctdbadddouble' instead of `tctdbput'. -px : the output data is converted into a hexadecimal data string. -pz : do not append line feed at the end of the output. -m num : specify the maximum number of the output. -pv : print values of records also. -fm str : specify the prefix of keys. -ord name type : specify the order of the result. -sk num : specify the number of skipped records. -kw : print KWIC string. -ph : print hint information also. -bt : specify the number of benchmark tests. -rm : remove every record in the result. -ms type : specify the set operation of meta search. -tz : enable the option `UINT8_MAX'. -df : perform defragmentation only. -it type : specify the index type among "lexical", "decimal", "token", "qgram", and "void". -cd : create the number index instead of the string index. -cv : remove the existing index. -sc : normalize keys as lower cases. The operator of the `search' subcommand is one of "STREQ", "STRINC", "STRBW", "STREW", "STRAND", "STROR", "STROREQ", "STRRX", "NUMEQ", "NUMGT", "NUMGE", "NUMLT", "NUMLE", "NUMBT", "NUMOREQ", "FTSPH", "FTSAND", "FTSOR", and "FTSEX". If "~" preposes each operator, the logi- cal meaning is reversed. If "+" preposes each operator, no index is used for the operator. The type of the `-ord' option is one of "STRASC", "STRDESC", "NUMASC", and "NUMDESC". The type of the `-ms' option is one of "UNION", "ISECT", and "DIFF". This command returns 0 on success, another on failure. SEE ALSO
tcttest(1), tctmttest(1), tctdb(3), tokyocabinet(3) Man Page 2011-02-12 TCTMGR(1)
All times are GMT -4. The time now is 05:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy