Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Is there a UNIX command that can compare fields of files with differing number of fields? Post 303035776 by Scrutinizer on Sunday 2nd of June 2019 11:52:15 PM
Old 06-03-2019
Quote:
Originally Posted by RudiC
Try
Code:
grep -vffile1 file2
XXXX01  APP_USER_EXP_PROFILE    LOCKED  2016-04-01=12:00
MICKEY  APP_USER_PROFILE        LOCKED  2018-04-01=16:00
DONALD  APP_USER_PROFILE        OPEN

and
Code:
grep -vf<(cut -d" " -f1-3 file2) file1
MINNIE  APP_USER_EXP_PROFILE
PLUTO   APP_USER_PROFILE

Note that this way, the spacing needs to be exactly the same for this to work. Also note that had PLUTO been present in y.txt it would still have been either listed as absent, because of the cut utility's single space separator, if the spacing were different, or listed as present on the basis of column 1 only and the exactly two spaces after it.

IMO, a more robust way is to use the spacing tolerance of for example awk plus exact string matching :
Code:
awk 'NR==FNR{A[$1,$2]; next} !(($1,$2) in A)' y.txt x.txt

or the other way around:
Code:
awk 'NR==FNR{A[$1,$2]; next} !(($1,$2) in A)' x.txt y.txt

This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

2. Shell Programming and Scripting

Compare fields in 2 files using AWK

Hi unix gurus, I have a urgent requirement, I need to write a AWK script to compare each fields in 2 files using AWK. Basically my output should be like this. file1 row|num1|num2|num3 1|one|two|three 2|one|two|three file2 row|num1|num2|num3 1|one|two|three 2|one|two|four ... (5 Replies)
Discussion started by: rashmisb
5 Replies

3. Shell Programming and Scripting

compare fields in different files

HI I'm having some troubles to compare and permut diffrent fields indexed with another filed like the following example `: file1 1 1 2 2 3 3 file2 7 1 9 2 10 3 result------------------- (6 Replies)
Discussion started by: yassinegoth
6 Replies

4. Shell Programming and Scripting

Compare fields in files

Hi, I need the most efficient way of comparing the following and arriving at the result I have a file which has entries like, File1: 1|2|5|7|8|2|3|6|3|1 File2: 1|2|3|1|2|7|9|2 I need to compare the entries in these two file with those of a general file, 1|2|3|5|2|5|6|9|3|1... (7 Replies)
Discussion started by: pradebban
7 Replies

5. Shell Programming and Scripting

Compare two fields in text files?

Hi, I have two text files, compare column one in both the files and if it matches then the output should contain the id in column one, the number and the description. Both the files are sorted. Is there a one liner to get this done, kindly help. Thank you File 1: NC_000964 92.33 ... (2 Replies)
Discussion started by: pulikoti
2 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Help correcting file with differing number of fields

Hi all, I have a tab separated file, and one of the fields is sub-delimited by colon. The problem is there can be zero to 4 colons within this field. When I try to change colons to tabs the result is a file with a differing number of fields. I want to go from: a:b:c:d:e a:b:c a:b:c:d:e a... (4 Replies)
Discussion started by: torchij
4 Replies

7. Shell Programming and Scripting

Compare three files based on two fields

Guys, I tried searching on the internet and I couldn't get the answer for this problem. I have 3 files. First 2 fields of all of them are of same type, say they come from various databases but first two fields in the 3 files means the same. I need to verify the entries that are not present... (4 Replies)
Discussion started by: PikK45
4 Replies

8. UNIX for Dummies Questions & Answers

Compare 2 fields in 2 files

I am trying to compare two files (separted by a pipe) using 2 fields (field 1,3 from fileA and 1,2 from fileB) if the two files match i want the whole record of fileA adding the extra fields left from fileB. 1. A.txt cat|floffy|12|anything|anythings cat|kitty|15|lala|lalala... (6 Replies)
Discussion started by: sabercats
6 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. Shell Programming and Scripting

Compare fields in two files

Hi, I am trying to check two files based on certain string and field. cat f1 source=\GREP\" hi this \\ source=\SED\" skdmsmd dnksdns source=\PERL\" cat f2 source=\SED\" source=\GREP\" vlamskds amdksk m source=\AWK\" awk \here\" (3 Replies)
Discussion started by: greet_sed
3 Replies
BNETD(1)							 The bnetd Project							  BNETD(1)

NAME
bnetd - Unix Battle.net daemon SYNOPSIS
bnetd [-f] [-c configfile] [-d dumpfile] DESCRIPTION
bnetd is a program that will eventually completely emulate a Blizzard Battle.net server. Currently Starcraft, Brood War, Diablo, and War- craft II BNE are supported as clients. It is known to work under most versions of Unix and can also be used under Windows as a win32 console application. OPTIONS
-c --config Use this configuration file instead of the compiled-in default location. -d --hexdump Put a hex dump of packets sent and received into the specified file. -f --foreground The server normally acts as a daemon and goes into the background. This forces the server to run in the foreground. -h --help --usage Print server usage information and exit. -v --version Print its version number and exit. FILES
bnetd.conf The main configuration file. Among other things, it specifies the locations for the other files used by the daemon. bnmotd.txt The "message of the day" file. This is displayed when the user enters the first chat channel. bnetd_default_user This is the default account file. The contains all default account attributes which are used when an attribute is not set on an actual account. channel.list This is the permanent channel list. Short names, target clients, and other attributes may be specified here. news.txt The contensts of this file are printed when the /news command is used. ad.list This is the ad banner list which determines which banners to display at which times. The order of display for the banners may be specified as well as the URL which they should follow when clicked. bnban The IP ban file can be used to block connections from certain addresses. bnhelp This file contains the the chat command help. gametrans The game address translation file can be used to allow players from behind a NAT firewall to play with those outside of the fire- wall. autoupdate This is the autoupdate MPQ archive list. It chooses which versions of which clients to update. tos.txt This is the Terms Of Service file that is displayed before a user can create a new account. icons.bni The icons which the client displays for players in the chat rooms. ad000001.pcx This is the ad Banner. Currently, it says "Welcome to... BNETD". NOTES
The current version is available at: http://www.bnetd.org/ SEE ALSO
bntrackd(1), bnproxy(1), bnchat(1), bnbot(1), bnpass(1), bnftp(1), bnetd.conf(5), bnmotd.txt(5) AUTHORS
Ross Combs (ross@bnetd.org), Rob Crittenden (rob@bnetd.org), and Mark Baysinger (mark@bnetd.org) BNETD
12 June, 2000 BNETD(1)
All times are GMT -4. The time now is 01:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy