Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Any way to get join to include the non-matching line ??? Post 303044576 by newbie_01 on Wednesday 26th of February 2020 11:55:53 PM
Old 02-27-2020
Any way to get join to include the non-matching line ???

Hi,


Need guidance if I should totally abandon join and use something else instead. I found several other options when searching for merge files in UNIX.com


Below are the test files to join:



Code:
$ head -1000 a.txt b.txt c.txt
==> a.txt <==
A|1
B|3
C|5
D|10
E|11

==> b.txt <==
A|4
B|5
C|4
D|1

==> c.txt <==
A|1
A|3
C|5
D|10
E|11

Running
Code:
$ join -t"|" -j1 a.txt b.txt

gives



Code:
A|1|4
B|3|5
C|5|4
D|10|1

Is there no way to get the E row from a.txt

Running
Code:
$ join -t"|" -j1 a.txt c.txt

. Is there no way to get the B row from a.txt printed?



Code:
A|1|1
A|1|3
C|5|5
D|10|10
E|11|11

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to join a line to the line that follows it

Hi All, I need a shell script to join a line to the line that follows it. But I shouldn't do it for all the lines. I need to join a line having the character say '&' at the end of the line & need to join the line that follows it. E.g Input 1. This is the first line & 2. and the second... (6 Replies)
Discussion started by: shashi_kiran_v
6 Replies

2. Shell Programming and Scripting

need for loop to include fields as one line

another question that could possibly be answered with awk... #cat filename ab cd ef:ghi:jk lm:nop qrs ab cd ef:ghi:jk lm:nop qrs ab cd ef:ghi:jk lm:nop qrs ab cd ef:ghi:jk lm:nop qrs # for x in `awk 'sub($1" +"$2" +","",$0) ' filename`; do echo $x; done ef:ghi:jk ... (8 Replies)
Discussion started by: prkfriryce
8 Replies

3. Shell Programming and Scripting

How to use Perl to join multi-line into single line

Hello, Did anyone know how to write a perl script to merge the multi-line into a single line where each line with start at timestamp Input--> timestamp=2009-11-10-04.55.20.829347; a; b; c; timestamp=2009-11-10-04.55.20.829347; aa; bb; cc; (5 Replies)
Discussion started by: happyday
5 Replies

4. Shell Programming and Scripting

Join 3 or more files using matching column

Dear Forum, Full title of the topic would be: "Join 3 or more files using matching column without full list in any of these columns" I have several, typically 3 or 4 files which I need to join, something like FULL JOIN in slq scripts, all combinations of matches should be printed into an... (3 Replies)
Discussion started by: cyz700
3 Replies

5. Shell Programming and Scripting

Matching the substring and join two files

Hi I had two files like below. file-1 101001234567890 101001234567891 101001234567892 101001234567893 101001234567894 101001234567895 101001234567896 101001234567897 101001234567898 101001234567899 file-2 (6 Replies)
Discussion started by: p_sai_ias
6 Replies

6. Shell Programming and Scripting

Join all the lines matching similar pattern

I am trying to Join all the lines matching similar pattern. Example ; I wanted to join all the lines which has sam to a single line. In next line, i wanted to have all the lines with jones to a single line....etc > cat sample.txt sam 2012/11/23 sam 2012/12/5 sam 2012/12/5 jones... (2 Replies)
Discussion started by: evrurs
2 Replies

7. Shell Programming and Scripting

Insert lines above matching line with content from matching

Hi, I have text file: Name: xyz Gender: M Address: "120_B_C; ksilskdj; lsudlfw" Zip: 20392 Name: KLM Gender: F Address: "65_D_F; wnmlsi;lsuod;,...." Zip:90233I want to insert 2 new lines before the 'Address: ' line deriving value from this Address line value The Address value in quotes... (1 Reply)
Discussion started by: ysrini
1 Replies

8. Shell Programming and Scripting

Join two files with matching columns

Hi, I need to join two files together with one common value in a column. I think I can use awk or join or a combination but I can't quite get it. Basically my data looks like this, with the TICKER columns matching up in each file File1 TICKER,column 1, column, 2, column, 3, column 4 ... (6 Replies)
Discussion started by: unkleruckus
6 Replies

9. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

10. Shell Programming and Scripting

Regex to include up to blank line.

Hi guys I am trying to figure out how to match a pattern with a regex up to a full blank line. I will show you what I mean with this example: example A movie name: ted movie name: TMNT movie name: Jinxed example B movie names: Gravity Faster Turbo song titles: dont hello problem (8 Replies)
Discussion started by: acoding
8 Replies
PESCETTI(1)						      General Commands Manual						       PESCETTI(1)

NAME
pescetti -- Pseudo-Duplimate Generator SYNOPSIS
pescetti DESCRIPTION
This manual page documents briefly the pescetti command. OPTIONS
Here are a list of the available options and what they do. You must specify exactly one from --demo, --generate or --load. --help Prints the help text --demo Demonstration mode. Generates one hand with permutations and the tutorial for how to use them. --generate=N Generate N random boards --load=boards.txt Load boards+analysis from boards.txt --load-dds=boards.dds Load boards from boards.dds in dds format --load-analysis=tricks.txt Load analysis from tricks.txt --permutations=permutations.txt Generate the permutations and save them to the given file --curtains=curtains.txt Save curtain cards to file curtains.txt --save=boards.txt Save the boards+analysis to boards.txt --save-dds=boards.dds Save the boards to boards.dds in dds format --save-analysis=tricks.txt Save the analysis to tricks.txt --format=html|txt|pdf Set the output mode to the given format --title=title Set the title for the output --output=hands.txt Print the hands to hands.txt, rather than to standard output --stats Generate statistics about the set of boards; included in the hands output --analyze Run the dds analyzer on the boards and print the resulting numberof tricks (warning SLOW) --criteria= A list of criteria to apply to each generated hand to generate specific hand types. The list should be space separated and each item may be suffixed with a colon and a (fractional) probability value which can be used to weight the criteria. E.g. --criteria="weaknt:0.8 strongnt:0.5" Valid criteria are: unbalanced weaknt strongnt twont strongtwo weaktwo three twoclubs 4441 singlesuit twosuits partscore game slam game-invite slam-invite jumpshift jumpfit splinter bacon weird --probability=factor Generate hands matching the criteria with only the given probability. Factor is in the range 0 to 1. On each attempt to generate a board it is rejected if it doesn't match the criteria with the given probability. A factor of about 0.8 gives roughly half matching boards AUTHOR
This manual page was written by Matthew Johnson <debian@matthew.ath.cx>. Permission is granted to copy, distribute and/or modify this docu- ment under the terms of the GNU General Public License, Version 2 as published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. PESCETTI(1)
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy