02-03-2006
Hey kingkong ,
Heres the solution
Quote:
max=0
cat file.txt|while read LINE
do
fir=`echo $LINE|awk '{print $2}'`
sec=`echo $LINE|awk '{print $3}'`
if [ $fir -gt $max ]; then
max=$fir
fi
if [ $sec -gt $max ];then
max=$sec
fi
done
grep $max file.txt
where your data is in file.txt
do let me know if it works
cheers ,
Gaurav
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a space delimited text file with thousands of lines, COLA.TXT that looks for example like this:
AA 123 456 789
AA 987 987 987
AA 987 988 888
AA 999 999 999
B 123 456 789
B 111 111 111
CCD 123 456 789
CCD 321 654 987
CCD
EE 11 11
EE
EE
EE 00 00 00
EE
Anyway, I need a script... (2 Replies)
Discussion started by: ajp7701
2 Replies
2. Shell Programming and Scripting
Hello folks,
Please guide me i have a file file.txt that have below text.
PETER JOHN peter@example.com
John Col john@example.com
Sara Paul sara@example.com
I just want to extract only email address list. (5 Replies)
Discussion started by: learnbash
5 Replies
3. Shell Programming and Scripting
I have a .csv file which is seperated with (;)
inputfile
---------
ZZZZ;AAAA;BBB;CCCC;DDD;EEE;
YYYY;BBBB;CCC;DDDD;EEE;FFF;
...
...
reading file line by line till end of file.
while reading each line output format should be .
i need to print only specific columns let say 5th... (2 Replies)
Discussion started by: rocking77
2 Replies
4. Shell Programming and Scripting
Hello,
I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2
SDF4 -0.211654
SDF4 0.978068
... (1 Reply)
Discussion started by: Diya123
1 Replies
5. Shell Programming and Scripting
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies
6. Shell Programming and Scripting
Hello everyone,
I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this:
20170628-23:25:01,1,0,0,1,1,1,1,55,55,1
20170628-23:30:01,1,0,0,1,1,1,1,56,56,1
20170628-23:35:00,1,0,0,1,1,2,1,57,57,2
20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies
7. Shell Programming and Scripting
Hi,
I have some data like below:
John 254
Chris 254
Matt 123
Abe 123
Raj 487
Moh 487
How can i print it using awk to have:
254 John,Chris
123 Matt,Abe
487 Raj,Moh
Thanks. (4 Replies)
Discussion started by: james2009
4 Replies
8. Shell Programming and Scripting
Hi, I have a little issue right now.
I have a file with 4 columns
test0000002,10030010330,c_,218
test0000002,10030010330,d_,202
test0000002,10030010330,b_,193
test0000002,10030010020,c_,178
test0000002,10030010020,b_,170
test0000002,10030010330,a_,166
test0000002,10030010020,a_,151... (3 Replies)
Discussion started by: Ebk
3 Replies
9. Shell Programming and Scripting
please help to write a awk command-line programs to achieve the following functions: Thank in advance.
Requeset Description:
compare two files f1 and f2, export to file f3:
1 Delete duplicate rows of in file f1 and file f2
2 If the 1th column of file f1 and file f2 is the same, then export... (1 Reply)
Discussion started by: weichanghe2000
1 Replies
10. Shell Programming and Scripting
Need your support for below. Please help to get required output
If column 5 is INV then only consider column1 and take out duplicates/identical rows/values from column1 and then put minimum value of column6 in column7 and put maximum value in column 8 and then need to do subtract values of... (7 Replies)
Discussion started by: as7951
7 Replies
LEARN ABOUT FREEBSD
xo_open_list_h
LIBXO(3) BSD Library Functions Manual LIBXO(3)
NAME
xo_emit -- emit formatted output based on format string and arguments
LIBRARY
library ``libxo''
SYNOPSIS
#include <libxo/xo.h>
LIBXO(3) BSD Library Functions Manual LIBXO(3)
NAME
xo_open_list
xo_open_list_h
xo_open_list_hd
xo_open_list_d
xo_open_instance
xo_open_instance_h
xo_open_instance_hd
xo_open_instance_d
xo_close_instance
xo_close_instance_h
xo_close_instance_hd
xo_close_instance_d
xo_close_list
xo_close_list_h
xo_close_list_hd
xo_close_list_d -- open and close lists and instances
LIBRARY
library ``libxo''
SYNOPSIS
int
xo_open_list_h(xo_handle_t *xop, const char *name);
int
xo_open_list(const char *name);
int
xo_open_list_hd(xo_handle_t *xop, const char *name);
int
xo_open_list_d(const char *name);
int
xo_open_instance_h(xo_handle_t *xop, const char *name);
int
xo_open_instance(const char *name);
int
xo_open_instance_hd(xo_handle_t *xop, const char *name);
int
xo_open_instance_d(const char *name);
int
xo_close_instance_h(xo_handle_t *xop, const char *name);
int
xo_close_instance(const char *name);
int
xo_close_instance_hd(xo_handle_t *xop);
int
xo_close_instance_d(void);
int
xo_close_list_h(xo_handle_t *xop, const char *name);
int
xo_close_list(const char *name);
int
xo_close_list_hd(xo_handle_t *xop);
int
xo_close_list_d(void);
DESCRIPTION
Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output
styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that
instance.
The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and
usage expectations.
A list is a set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can
think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close
each instance of the list:
xo_open_list("item");
for (ip = list; ip->i_title; ip++) {
xo_open_instance("item");
xo_emit("{L:Item} '{:name/%s}':0, ip->i_title);
xo_close_instance("item");
}
xo_close_list("item");
Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.
EXAMPLE:
xo_open_list("user");
for (i = 0; i < num_users; i++) {
xo_open_instance("user");
xo_emit("{k:name}:{:uid/%u}:{:gid/%u}:{:home}0,
pw[i].pw_name, pw[i].pw_uid,
pw[i].pw_gid, pw[i].pw_dir);
xo_close_instance("user");
}
xo_close_list("user");
TEXT:
phil:1001:1001:/home/phil
pallavi:1002:1002:/home/pallavi
XML:
<user>
<name>phil</name>
<uid>1001</uid>
<gid>1001</gid>
<home>/home/phil</home>
</user>
<user>
<name>pallavi</name>
<uid>1002</uid>
<gid>1002</gid>
<home>/home/pallavi</home>
</user>
JSON:
user: [
{
"name": "phil",
"uid": 1001,
"gid": 1001,
"home": "/home/phil",
},
{
"name": "pallavi",
"uid": 1002,
"gid": 1002,
"home": "/home/pallavi",
}
]
LEAF LISTS
In contrast to a list of instances, a "leaf list" is list of simple values. To emit a leaf list, call the xo_emit() function using the ""l""
modifier:
for (ip = list; ip->i_title; ip++) {
xo_emit("{Lwc:Item}{l:item}0, ip->i_title);
}
The name of the field must match the name of the leaf list.
In JSON, leaf lists are rendered as arrays of values. In XML, they are rendered as multiple leaf elements.
JSON:
"item": "hammer", "nail"
XML:
<item>hammer</item>
<item>nail</item>
ADDITIONAL DOCUMENTATION
Complete documentation can be found on github:
http://juniper.github.io/libxo/libxo-manual.html
libxo lives on github as:
https://github.com/Juniper/libxo
The latest release of libxo is available at:
https://github.com/Juniper/libxo/releases
SEE ALSO
xo_emit(3)
HISTORY
The libxo library was added in FreeBSD 11.0.
AUTHOR
Phil Shafer
BSD
December 4, 2014 BSD