Sponsored Content
Full Discussion: Max value Record from a File
Top Forums Shell Programming and Scripting Max value Record from a File Post 302609917 by traininfa on Wednesday 21st of March 2012 10:08:45 AM
Old 03-21-2012
Max value Record from a File

I have a file with 3 columns

I want to get the record with the max salary. If there are more than 1 record having the highest salary, i want any one of them.
Code:
empid,ename,Sal
1,abc,100
2,def,200
3,xyz,300
4,pqr,100
5,mnq,300


Output
Any record with 300 as salary

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data, avoid adding color or different fonts and font size to your posts.


---------- Post updated 03-21-12 at 10:08 AM ---------- Previous update was 03-20-12 at 03:14 PM ----------

I was sorting based on the amount column and then doing a head -1 for the data.Is this the correct approach?

Last edited by vbe; 03-21-2012 at 06:11 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

splitting a record and adding a record to a file

Hi, I am new to UNIX scripting and woiuld appreicate your help... Input file contains only one (but long) record: aaaaabbbbbcccccddddd..... Desired file: NEW RECORD #new record (hardcoded) added as first record - its length is irrelevant# aaaaa bbbbb ccccc ddddd ... ... ... (1 Reply)
Discussion started by: rsolap
1 Replies

2. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies

3. Shell Programming and Scripting

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (2 Replies)
Discussion started by: shilendrajadon
2 Replies

4. UNIX for Dummies Questions & Answers

how to read record by record from a file in unix

Hi guys, i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a... (1 Reply)
Discussion started by: raoscb
1 Replies

5. Linux

file-max limit

Oct 31 00:00:02 FIREWALL003 syslogd 1.4.1: restart. Oct 31 00:00:02 FIREWALL003 syslogd 1.4.1: restart. Oct 31 00:00:02 FIREWALL003 syslogd 1.4.1: restart. Oct 31 02:37:09 FIREWALL003 kernel: srmLINUX: segfault at 00000000303a3031 rip 000000000026fe54 rsp 00000000ffbd05b8 error 4 Oct 31... (5 Replies)
Discussion started by: itik
5 Replies

6. Shell Programming and Scripting

Select record with MAX value in MySQL

Hi there, I have trouble selecting record that contain one biggest value for a group of other values. I mean, this is my table: mysql> SELECT * FROM b; +----+------+-------+ | id | user | value | +----+------+-------+ | 1 | 1 | 100 | | 3 | 1 | 150 | | 5 | 1 | 300 | | 6... (20 Replies)
Discussion started by: chebarbudo
20 Replies

7. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

8. Shell Programming and Scripting

Extract timestamp from first record in xml file and it checks if not it will replace first record

I have test.xml <emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp> <Join><id>101</id><city>london</city><date>06/06/14 2011</date></join> <Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join> <Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies

9. Shell Programming and Scripting

Script to record max memory usage of program

Hello, I am working on an application that uses allot of memory depending on the input. I am also working on more than one processing algorithm. The program has a long processing time (hours) so it would be nice to be able to monitor the maximum memory footprint of the application during runs... (1 Reply)
Discussion started by: LMHmedchem
1 Replies
Class::DBI::Test::SQLite(3pm)				User Contributed Perl Documentation			     Class::DBI::Test::SQLite(3pm)

NAME
Class::DBI::Test::SQLite - Base class for Class::DBI tests SYNOPSIS
use base 'Class::DBI::Test::SQLite'; __PACKAGE__->set_table('test'); __PACKAGE__->columns(All => qw/id name film salary/); sub create_sql { return q{ id INTEGER PRIMARY KEY, name CHAR(40), film VARCHAR(255), salary INT } } DESCRIPTION
This provides a simple base class for Class::DBI tests using SQLite. Each class for the test should inherit from this, provide a create_sql() method which returns a string representing the SQL used to create the table for the class, and then call set_table() to create the table, and tie it to the class. METHODS
set_table __PACKAGE__->set_table('test'); This combines creating the table with the normal Class::DBI table() call. create_sql (abstract) sub create_sql { return q{ id INTEGER PRIMARY KEY, name CHAR(40), film VARCHAR(255), salary INT } } This should return, as a text string, the schema for the table represented by this class. perl v5.12.4 2005-05-24 Class::DBI::Test::SQLite(3pm)
All times are GMT -4. The time now is 06:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy