I did my best to not make any assumptions regarding your assumptions (I was somewhat puzzled by the choice of negative three to trigger the printing of a record, but I kept it )
Regards,
alister
---------- Post updated at 03:01 PM ---------- Previous update was at 12:29 PM ----------
As i understand the problem, ahmad.diab's solution is incorrect but it did make me realize that i was over-engineering. A simpler approach inspired by his post (the only advantage of the modulus-based solution above is that it can readily handle MxN, and not just 4xN, if the hardcoded 4 is parameterized).
The following gives the same output given the same sample data files (data3 and data4) used above.
alister
Last edited by alister; 01-06-2010 at 04:18 PM..
Reason: perhaps i have ocd :)
Hi,
I need to do a sum of two columns in a file where delimiter is |^
input
1|^2|^3|^4|^50|^2|^3|^100
2|^3|^4|^6|^100|^7|^2|^50
3|^4|^2|^3|^50|^6|^3|^50
4|^2|^5|^7|^25|^2|^8|^25
Output required:
Sum of 2 columns 5 & 8 which is 450 (11 Replies)
Hi Friends,
I have come across some files where some of the columns don not have data.
Key, Data1,Data2,Data3,Data4,Data5
A,5,6,,10,,
A,3,4,,3,,
B,1,,4,5,,
B,2,,3,4,,
If we see the above data on Data5 column do not have any row got filled. So remove only that column(Here Data5) and... (4 Replies)
Hi all, I know this sounds suspiciously like a homework course; but, it is not.
My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Hi everyone,
Here are the contents of a plain text file created by a SQL query:
SUM(T.TRNQTY) COUNT(D.TRNSEQ)
---------------- ----------------
1380 46
1393 59
2680 134
740 37
... (5 Replies)
My File looks like:
"|" -> Field separator
A|B|C|100|1000
D|E|F|1|2
G|H|I|0|7
D|E|F|1|2
A|B|C|10|10000
G|H|I|0|7
A|B|C|1|100
D|E|F|1|2
I need to do a SUM on Col. 5 and Col.6 by grouping on Col 1,2 & 3
My expected output is:
A|B|C|111|11100 (2 Replies)
HI All,
I'm embedding SQL query in Script which gives following output:
Assignee Group Total
ABC Group1 17
PQR Group2 5
PQR Group3 6
XYZ Group1 10
XYZ Group3 5
I have saved the above output in a file.
How do i sum up the contents of this output so as to get following output:
... (4 Replies)
Dear Experts,
I have input file which is comma separated, has 4 columns like below,
BRAND,COUNTRY,MODEL,COUNT
NIKE,USA,DUMMY,5
NIKE,USA,ORIGINAL,10
PUMA,FRANCE,DUMMY,20
PUMA,FRANCE,ORIGINAL,15
ADIDAS,ITALY,DUMMY,50
ADIDAS,ITALY,ORIGINAL,50
SPIKE,CHINA,DUMMY,1O
And expected output add... (2 Replies)
I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv
abc.csv-
UTF-8,,,,,,,,,,,,,,,,,,,,,,,,,
... (6 Replies)
Optimization shell/awk script to aggregate (sum) for all the columns of Huge data file
File delimiter "|"
Need to have Sum of all columns, with column number : aggregation (summation) for each column
File not having the header
Like below -
Column 1 "Total
Column 2 : "Total
...
...... (2 Replies)
Discussion started by: kartikirans
2 Replies
LEARN ABOUT HPUX
tabs
tabs(1) General Commands Manual tabs(1)NAME
tabs - set tabs on a terminal
SYNOPSIS
[tabspec] n] type]
DESCRIPTION
sets the tab stops on the user's terminal according to the tab specification tabspec, after clearing any previous settings. The user's
terminal must have remotely-settable hardware tabs.
If you are using a non-HP terminal, you should keep in mind that behavior will vary for some tab settings.
Four types of tab specification are accepted for tabspec: ``canned'', repetitive, arbitrary, and file. If no is given, the default value
is i.e., UNIX ``standard'' tabs. The lowest column number is 1. Note that for tabs, column 1 always refers to the left-most column on a
terminal, even one whose column markers begin at 0.
Gives the name of one of a set of ``canned'' tabs.
Recognized codes and their meanings are as follows:
1,10,16,36,72
Assembler, IBM S/370, first format
1,10,16,40,72
Assembler, IBM S/370, second format
1,8,12,16,20,55
COBOL, normal format
1,6,10,14,49
COBOL compact format (columns 1-6 omitted). Using this code, the first typed character corresponds to card column 7,
one space gets you to column 8, and a tab reaches column 12. Files using this tab setup should have specify a format
specification file as defined by below. The file should have the following format specification:
1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67
COBOL compact format (columns 1-6 omitted), with more tabs than This is the recommended format for COBOL. The appro-
priate format specification is:
1,7,11,15,19,23
FORTRAN
1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61
PL/I
1,10,55
SNOBOL
1,12,20,44
UNIVAC 1100 Assembler
In addition to these ``canned'' formats, three other types exist:
A repetitive specification requests tabs at columns
1+n, 1+2xn, etc. Of particular importance is the value this represents the UNIX ``standard'' tab setting, and is the most
likely tab setting to be found at a terminal. Another special case is the value implying no tabs at all.
The arbitrary format permits the user to type any
chosen set of numbers, separated by commas, in ascending order. Up to 40 numbers are allowed. If any number (except the first
one) is preceded by a plus sign, it is taken as an increment to be added to the previous value. Thus, the tab lists 1,10,20,30
and 1,10,+10,+10 are considered identical.
If the name of a file is given,
reads the first line of the file, searching for a format specification. If it finds one there, it sets the tab stops according
to it, otherwise it sets them as This type of specification can be used to ensure that a tabbed file is printed with correct
tab settings, and is suitable for use with the command (see pr(1)):
Any of the following can be used also; if a given option occurs more than once, the last value given takes effect:
usually needs to know the type of terminal in order to set tabs
and always needs to know the type to set margins. type is a name listed in term(5). If no option is supplied, searches for
the value in the environment (see environ(5)). If is not defined in the environment, tries a sequence that will work for many
terminals.
The margin argument can be used for some terminals.
It causes all tabs to be moved over n columns by making column n+1 the left margin. If is given without a value of n, the
value assumed is 10. The normal (left-most) margin on most terminals is obtained by The margin for most terminals is reset
only when the option is given explicitly.
Tab and margin setting is performed via the standard output.
EXTERNAL INFLUENCES
Environment Variables
determines the interpretation of text within file as single- and/or multi-byte characters.
determines the language in which messages are displayed.
If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of
If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See
environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
DIAGNOSTICS
Arbitrary tabs are ordered incorrectly.
A zero or missing increment found in an arbitrary specification.
A ``canned'' code cannot be found.
option was used and file cannot be opened.
option was used and the specification in that file
points to yet another file. Indirection of this form is not permitted.
WARNINGS
There is no consistency among different terminals regarding ways of clearing tabs and setting the left margin.
It is generally impossible to usefully change the left margin without also setting tabs.
clears only 20 tabs (on terminals requiring a long sequence), but is willing to set 64.
SEE ALSO nroff(1), pr(1), tset(1), environ(5), term(5).
STANDARDS CONFORMANCE tabs(1)