Sponsored Content
Top Forums Shell Programming and Scripting Compare fields and keep record with bigger ID? Post 302771442 by sabercats on Wednesday 20th of February 2013 04:06:34 PM
Old 02-20-2013
Okay I made it work now with this code
Code:
awk -F"|" '$1>=highest[$2,$3,$4,$5,$6,$7]{maxrec[$2,$3,$4,$5,$6,$7]=$0;highest[$2,$3,$4,$5,$6,$7]=$1} END{for(i in maxrec)print maxrec[i]}' filename.txt | sort -t\| -k1

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to screen each variable record for right # of fields

Hi, In a script I have to check that input text files with a variable number of tab delimited fields have at least n fields and no more than m fields. Records are delimited by <CR> and <LF>. I have figured out code that will strip out all the alpha-numeric characters, convert the tabs to... (3 Replies)
Discussion started by: jvander
3 Replies

2. Shell Programming and Scripting

awk: record has too many fields

Hi, I'm trying this command - but get this error. Do you guys have any workaround for this? cat tf|sed 's/{//g'|sed 's/,//g'|awk '{for (i=1;i<=NF;i++) {if ($i == "OPTIME") {k = i + 2; print $i,$k}}}' awk: record `2005 Jul 28 17:35:29...' has too many fields record number 15 This is how... (3 Replies)
Discussion started by: chaandana
3 Replies

3. Shell Programming and Scripting

Manipulating fields record wise

Hi all, I have an input file with no delimiter. Let us say the file is abc.txt having values for fields namely, EmpNumEnameDesigSalDept. Ofcourse the file has got several records. Every field has got a fixed start and end position. I need to assign the fields to corresponding varibles say... (1 Reply)
Discussion started by: rinku11
1 Replies

4. Shell Programming and Scripting

Compare two arrays in sh or compare two fields

I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies

5. Shell Programming and Scripting

Making changes in the fields of a record

:confused: Hi Friends, In the record below i have to make changes in the fields by putting the values stored in the temporary variables, x, y, z, p, q, r: 2) In the TBT record store the values in the various fields as: a) X in a field position 51 to 56 b) Y... (5 Replies)
Discussion started by: kanu_pathak
5 Replies

6. Shell Programming and Scripting

Print all the fields of record using awk

Hi, i want to generate print statement using awk. i have 20+ and 30+ fields in each line Now its priting only first eight fields print statement as output not all. my record is as shown below filename ... (2 Replies)
Discussion started by: raghavendra.nsn
2 Replies

7. Shell Programming and Scripting

zsh compare size pdf and delete bigger?

I have used an script to reduce the size of multiples pdf. This script creates files with the same name but with different extension. The extension of the compressed files is xpdf. Sometimes the "compressed" xpdf are bigger than the "uncompressed"pdf. I want to create a zsh script to compare each... (1 Reply)
Discussion started by: AMDx64BT
1 Replies

8. Shell Programming and Scripting

How to compare current record,with next and previous record in awk without using array?

Hi! all can any one tell me how to compare current record of column with next and previous record in awk without using array my case is like this input.txt 0 32 1 26 2 27 3 34 4 26 5 25 6 24 9 23 0 32 1 28 2 15 3 26 4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies

9. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
jdbreg(8)						      System Manager's Manual							 jdbreg(8)

NAME
jdbreg - Registers hosts in the DHCP dynamic databases. SYNOPSIS
/usr/sbin/jdbreg [-d] [-e] [-f character] [-s] [-l | -n] [-o] [-w] filename... OPTIONS
Deletes the records whose keys are implied by the input file(s). Uses character as the field separator. The default is the pipe | charac- ter. Display all currently registered hosts. DESCRIPTION
The jdbreg program registers (or removes) hosts for configuration by DHCP. When the registered_hosts_only policy is in effect, the server configure only clients whose MAC addresses are so registered. When this policy is not in effect, registering hosts has no effect. Each record to be loaded is terminated by a newline, and the fields within each record delimited by default with the pipe (|) character, although this may be changed with the -f command line option. The fields within the data file(s) to be loaded are as follows: MAC address MAC address type MAC address length (octets) RESTRICTIONS
Because the database used by join does not support multiuser concurrently, applications that write to it, lock the entire database. This means that you cannot use jdbreg while joind is running. The converse is also true. FILES
SEE ALSO
Commands: joind(8) jdbreg(8)
All times are GMT -4. The time now is 10:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy