If you're willing to accept output with values in each column presented in the same order as they were seen in encountered in the input, you could try something like:
which, with the sample data you provided, produces the output:
If you need the last column to be in a different order, you need to more clearly explain your requirements. Hopefully, you can use the above code as a base to get something that will do what you're trying to do.
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk.
These 2 Users Gave Thanks to Don Cragun For This Post:
Dear All,
I want to get help for below case.
I have a file like this.
saman 1
gihan 2
saman 4
ravi 1
ravi 2
so i want to get the result,
saman 5
gihan 2
ravi 3 like this.
Pls help me. (17 Replies)
Hi All,
I have a file which is having 3 columns as (string string integer)
a b 1
x y 2
p k 5
y y 4
.....
.....
Question:
I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Hi ,
Can You Please let Know How use unix uniq command on a single column for deleting records from file
with Below Structure.Pipe Delimter File .
Source
Name | Account_Id
A | 101
B... (2 Replies)
Hi Gurus,
I have a tab separated text file with two columns. I would like to make the first column values as headings for the second column values.
Ex.
>value1 subjects
>value2 priorities
>value3 requirements
...etc
and I want to have a file
>value1
subjects
>value2
priorities... (4 Replies)
Hi,
I have a file as listed below.. What I want to get is for each unique value in column 1 the corresponding values in the rest of the columns should be summed up..
AAK1 0 1 0 11
AAK1 0 0 1 1
AAK1 0 0 1 2... (2 Replies)
I met a challenge to filter ~70 millions of sequence rows and I want using awk with conditions:
1) longest string of each pattern in column 2, ignore any sub-string, as the index;
2) all the unique patterns after 1);
3) print the whole row;
input:
1 ABCDEFGHI longest_sequence1
2 ABCDEFGH... (12 Replies)
Hello
How can I get a number of occurrence count for this file;
ERR315389.1000156 CTTGAAGAAGAATTGAAAACTGTGACGAACAACTTGAAGTCACTGGAGGCTCAGGCTGAGAAGTACTCGCAGAAGGAAGACAGATATGAGGAAGAG
ERR315389.1000281 ... (3 Replies)
I want to bring values in the second column into single line for uniq value in the first column.
My input
jvm01, Web 2.0 Feature Pack Library
jvm01, IBM WebSphere JAX-RS
jvm01, Custom01 Shared Library
jvm02, Web 2.0 Feature Pack Library
jvm02, IBM WebSphere JAX-RS
jvm03, Web 2.0 Feature... (10 Replies)
Hi All,
I have a directory and sub-directory that having ‘n' number of .log file in nearly 1GB.
The file is comma separated file. I need to recursively grep and uniq first column values only.
I did in perl. But i wish to know more command line utilities to calculate the time for grep and... (4 Replies)
Discussion started by: k_manimuthu
4 Replies
LEARN ABOUT DEBIAN
gd_validate
gd_validate(3) GETDATA gd_validate(3)NAME
gd_validate -- check a dirfile field code for validity
SYNOPSIS
#include <getdata.h>
int gd_validate(DIRFILE *dirfile, const char *field_code);
DESCRIPTION
The gd_validate() function queries a dirfile(5) database specified by dirfile and checks whether field_code, which may contain a represen-
tation suffix, specifies a valid field.
The dirfile argument must point to a valid DIRFILE object previously created by a call to gd_open(3).
This function checks whether the field and its input fields (if any) are found, whether the representation suffix (if any) is valid, and
also that all non-literal parameters specify valid scalar fields.
RETURN VALUE
If all checks pass, gd_validate() returns zero. On error, it returns -1 and sets the dirfile error to a non-zero error value. Possible
error values are:
GD_E_BAD_CODE
The field specified by field_code or one of the fields it uses as input was not found in the database.
GD_E_BAD_DIRFILE
The supplied dirfile was invalid.
GD_E_BAD_REPR
The representation suffix specified in field_code was not recognised.
GD_E_BAD_SCALAR
A non-literal scalar used in the definition of the field or one of its inputs was not found, or was not a CONST or CARRAY field.
GD_E_DIMENSION
A scalar field was found where a vector field was expected.
GD_E_RECURSE_LEVEL
Too many levels of recursion were encountered while trying to resolve field_code. This usually indicates a circular dependency in
field specification in the dirfile.
The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from
a call to gd_error_string(3).
NOTES
It is not necessary to call this function before passing a field code to another GetData function: all functions which accept field codes
perform these checks themselves.
SEE ALSO dirfile(5), gd_getdata(3), gd_error(3), gd_error_string(3), gd_open(3)Version 0.7.0 3 November 2010 gd_validate(3)