Sponsored Content
Top Forums Shell Programming and Scripting Simple comparison between two lists. Post 302890114 by RudiC on Tuesday 25th of February 2014 09:09:19 AM
Old 02-25-2014
Try also
Code:
awk     'NR == FNR      {T[$1]=$2;next}
         $2 == T[$1]    {delete T[$1]; next}
                        {printf "| %s=%s |",$1,$2;
                         if (T[$1]!="") printf " %s=%s |\n", $1, T[$1]
                         else           printf "  -- |\n"
                         delete T[$1]
                        }
         END            {for (i in T) printf "|  -- | %s=%s |\n", i, T[i]}
        ' file1 file2
| a=1 |  -- |
| z=4 | z=3 |

These 3 Users Gave Thanks to RudiC For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the files lists

Hi All, Need the help in getting the file list which are generated for the time period. example if i want to get the list of file generated between 11 to 12 clock. i used the find command search the files with -cmin flag with -60. find /home/test/* -cmin -60 -type f -exec ls {} \; ... (2 Replies)
Discussion started by: nmadhuhb
2 Replies

2. Shell Programming and Scripting

Simple XML file comparison and merging

Okay, first of all, thanks to everyone who's helped me out before... I appreciate the opportunity to learn. I have two iTunes XML files, and I simply want to compare the contents, then merge. Theoretically, this will allow me to merge two libraries, keeping playlists intact (depending on iTunes'... (4 Replies)
Discussion started by: karlp
4 Replies

3. Shell Programming and Scripting

Shell Script to Create non-duplicate lists from two lists

File_A contains Strings: a b c d File_B contains Strings: a c z Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below. Resultant... (7 Replies)
Discussion started by: mlv_99
7 Replies

4. Shell Programming and Scripting

Comparison between 2 large lists with Getting VALUES from one into the other

hi, I have 2 large lists: LIST A: containes 6 fields of many entries (VARIABLE number), like: 2011-07-10 | 18:19:47 | 38037300 | 9647808003122 | 2 | success LIST B: containes 3 fields & 183 entries (FIXED number), like: 9647805651885 9647805651885 SCP_10 What I want is a... (8 Replies)
Discussion started by: amurib
8 Replies

5. Shell Programming and Scripting

combining two lists

Hi, So I I received two lists for my merchandise and both are similar but differences do occur. I want to combine two lists that have similar names but I dont want the similar name to come up twice because I will end up purchasing two of those items. Heres an example below (file is massive). ... (1 Reply)
Discussion started by: kylle345
1 Replies

6. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

7. Shell Programming and Scripting

Need help with simple comparison in AWK

Hi, I'm new to AWK and I'm having problems comparing a field to a string variable. /ARTIST/ {x = $2} $1 ~ x {print $0}My code tries to find a record with the string "ARTIST". Once it finds it, it stores the second field of the record into a variable. I don't know what the problem is for the... (7 Replies)
Discussion started by: klusps
7 Replies

8. Shell Programming and Scripting

get the lists

I expert, I may cross post something similar but I dirtyed my quesion somehow to be clear in the thread #cat file1 88dee gcc: Grok for callconvention-hard to enable hard float a2ad2 eglibc: package mtrace separately 61487 python: bump PR of packages after update of distutils.bbclass... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

9. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies
COMBINE(1)																COMBINE(1)

NAME
combine - combine sets of lines from two files using boolean operations SYNOPSIS
combine file1 and file2 combine file1 not file2 combine file1 or file2 combine file1 xor file2 _ file1 and file2 _ _ file1 not file2 _ _ file1 or file2 _ _ file1 xor file2 _ DESCRIPTION
combine combines the lines in two files. Depending on the boolean operation specified, the contents will be combined in different ways: and Outputs lines that are in file1 if they are also present in file2. not Outputs lines that are in file1 but not in file2. or Outputs lines that are in file1 or file2. xor Outputs lines that are in either file1 or file2, but not in both files. "-" can be specified for either file to read stdin for that file. The input files need not be sorted, and the lines are output in the order they occur in file1 (followed by the order they occur in file2 for the two "or" operations). Bear in mind that this means that the operations are not commutative; "a and b" will not necessarily be the same as "b and a". To obtain commutative behavior sort and uniq the result. Note that this program can be installed as "_" to allow for the syntactic sugar shown in the latter half of the synopsis (similar to the test/[ command). It is not currently installed as "_" by default, but you can alias it to that if you like. SEE ALSO
join(1) AUTHOR
Copyright 2006 by Joey Hess <joey@kitenet.net> Licensed under the GNU GPL. moreutils 2012-04-09 COMBINE(1)
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy