Sponsored Content
Top Forums Shell Programming and Scripting Comparing columns in two separate files Post 302633797 by dgaff on Wednesday 2nd of May 2012 12:32:18 PM
Old 05-02-2012
Comparing columns in two separate files

Hey all, I have a file structure that looks something like this:

file1
Code:
306708278
88954535
234167885

file2
Code:
2012-03-27T12:32:56+00:00	137		Orchotorena	184616310003601409	306708278	es	40.4777947	Majadahonda	-3.6416896333333333	0	false	atlante83	"<a href=""http://tapbots.com/tweetbot"" rel=""nofollow"">Tweetbot for iOS</a>"	@Orchotorena un negro en edición es una imágen sin luminancia o negra. Se puede usar intencionalmente para separar planos	false	184619011038920705	88954535
2012-03-27T12:32:56+00:00	137		elasadumz	184617507607429120	238467064	id	-6.168961	Surakarta, Indonesia	106.83324766666668	0	false	Eka_put3	web	@elasadumz loh aku og gx d sapa???	false	184619010195849216	386451538
2012-03-27T12:32:57+00:00	137					en	-3.109555	no ♥ da minha gatinha.	-60.009778	0	false	jessicavaanessa	"<a href=""http://foursquare.com"" rel=""nofollow"">foursquare</a>"	I just ousted Guilherme C. as the mayor of Bebedouro Do Ceme on @foursquare! http://t.co/CfIF2LTm	false	184619011361869825	192336667
2012-03-27T12:32:57+00:00	137					en	-3.109555	no ♥ da minha gatinha.	-60.009778	0	false	jessicavaanessa	"<a href=""http://foursquare.com"" rel=""nofollow"">foursquare</a>"	I'm at Bebedouro Do Ceme (Manaus, Amazonas) http://t.co/7ZM7caXy	false	184619011592552448	192336667
2012-03-27T12:32:57+00:00	137					en	59.0687737	Oslo, Norway	11.529263533333333	0	false	jonarnesen	web	...dømt i går, pågrepet i dag for nyere forhold, og noen klager på at prøvetiden på førerkort ikke fungerer... #mullahkrekar #krekar #mullah	false	184619011747741697	18520064
2012-03-27T12:32:57+00:00	137					ja	34.7054449	大阪府	135.49594045	0	false	mucchi0312	"<a href=""http://foursquare.com"" rel=""nofollow"">foursquare</a>"	I'm at Supporter's Field http://t.co/xdHMBFyC	false	184619011697426432	495949802
2012-03-27T12:32:57+00:00	137					it	39.391708799999996	CA-Sardinia Magic Island 	9.3025356	0	false	AaronnMax	web	Listenin.... Jimmy Reed	false	184619011689033728	445455678
2012-03-27T12:32:57+00:00	137					en	3.1484500499999997	kuala lumpur	101.71766273333333	0	false	RainaBalqis	web	Kalau dj tak suka sgt ngn aku, tukar je lah tempat duduk aku.Takyah nk simpan dlm benak kau tu.	false	184619011991027712	234167885

And, what I'm looking to do is to isolate the rows from file2 where file1 is matched in either file2's 6th or 18th columns. A simple grep won't do it because in reality, file1 is too large to just pass along - definitely more than a couple hundred thousand lines. So, anyone have an idea on this? Also, obviously, this is my first post, so if I screwed up my post, that's why. I've been looking for the past few hours at sed, awk, and grep and comm and all sorts of combinations and tweaks, but can't hack this one out, as I'm getting to the limits of understanding how shell scripting works.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Comparing Columns of two FIles

Dear all, I have two files in UNIX File1 and File2 as below: File1: 1,1234,.,67.897,,0 1,4134,.,87.97,,4 0,1564,.,97.8,,1 File2: 2,8798,.,67.897,,0 2,8879,.,77.97,,4 0,1564,.,97.8,,1 I want to do the following: (1) Make sure that both the files have equal number of columns and if... (1 Reply)
Discussion started by: ggopal
1 Replies

2. Shell Programming and Scripting

Comparing Columns of two FIles

Dear all, I have two files in UNIX File1 and File2 as below: File1: 1,1234,.,67.897,,0 1,4134,.,87.97,,4 0,1564,.,97.8,,1 File2: 2,8798,.,67.897,,0 2,8879,.,77.97,,4 0,1564,.,97.8,,1 I want to do the following: (1) Make sure that both the files have equal number of columns and if... (4 Replies)
Discussion started by: ggopal
4 Replies

3. Shell Programming and Scripting

Comparing Counts Within Separate Files

Hey all, So I have this challenge where I am attempting to compare record counts from within several different log files. I want input and output counts for each file, and I want to compare that with the result of the input/output comparison from a separate--but related file. Example: ... (2 Replies)
Discussion started by: gator76
2 Replies

4. UNIX for Dummies Questions & Answers

Comparing 2 columns from 2 files

Hi, I have two files with the same number of columns. Basically I want to print the 2 columns that match between the two files. File1 looks like this: dr12 12 6 abn dr14 12 7 abn File2 looks something like this: dr12 12 8 abn dr12 14 7 abn So basically if the first... (1 Reply)
Discussion started by: kylle345
1 Replies

5. UNIX for Dummies Questions & Answers

Comparing columns in two files

Hi, I have two files. File1.txt has 2 columns and looks like: 458739 122345 4456 122657 34200 122600 File2.txt has many columns with column 1 the same as column2 of File1.txt, but with lot more rows: 122786 abcdefg user1@email 122778 uuhjeufh user2@email... (1 Reply)
Discussion started by: ursaan
1 Replies

6. Shell Programming and Scripting

comparing two columns from two different files

Hello, I have two files as 1.txt and 2.txt with number as columns. 1.txt 0 53.7988 1 -30.0859 2 20.1632 3 14.2135 4 14.6366 5 -37.6258 . . . 31608 -8.57333 31609 -2.58554 31610 -24.2857 2.txt (1 Reply)
Discussion started by: AKD
1 Replies

7. Shell Programming and Scripting

Comparing two columns from two different files

Hi, I have a single-column file1 having records like: 00AB01/11 43TG22/00 78RC09/34 ...... ...... and a second file , file 2 having two columns like 78RC09/34 1 45FD11/11 2 00AB01/11 3 43TG22/00 4 ...... ...... (8 Replies)
Discussion started by: amarn
8 Replies

8. UNIX for Dummies Questions & Answers

Intersect of two columns in two separate files

Hi, I have a file like this: abc def ghi jkl mno My second file is like this (tab delimited): adsad sdfsdf dfdf wads abc dfdsf sdsf jkl sfsdf dsfds sdfd reor zxczd dsf sff Now, I want the code to report the lines (from file2) which have common strings in column 2 with the first... (4 Replies)
Discussion started by: a_bahreini
4 Replies

9. Shell Programming and Scripting

Separate columns into different text files

Hi I have large text file consisting of five columns. Sample of the file is give below: ed 2-4 12.0 commons that they depended on. मानवों नष्ट किया जिन पर वो आधारित थे। ed 3-1 12.0 Almost E, but would be over. रचना करीब करीब ई तक जाती है, मगर तब तो नाटक ख़त्म हो... (2 Replies)
Discussion started by: my_Perl
2 Replies

10. UNIX for Beginners Questions & Answers

How to use "awk" to print columns from different files in separate columns?

Hi, I'm trying to copy and paste the sixth column from a bunch of files into a single file having each column pasted in separate columns (and not one after each other in just one column.) I tried this code but works only partially because it copied and pasted 50 rows of each column... (6 Replies)
Discussion started by: Frastra
6 Replies
RDF::Trine::Node(3pm)					User Contributed Perl Documentation				     RDF::Trine::Node(3pm)

NAME
RDF::Trine::Node - Base class for RDF Nodes VERSION
This document describes RDF::Trine::Node version 1.000 FUNCTIONS
"ntriples_escape ( $value )" Returns the passed string value with special characters (control characters, Unicode, etc.) escaped, suitable for printing inside an N-Triples or Turtle encoded literal. METHODS
"is_node" Returns true if this object is a RDF node, false otherwise. "is_nil" Returns true if this object is the nil-valued node. "is_blank" Returns true if this RDF node is a blank node, false otherwise. "is_resource" Returns true if this RDF node is a resource, false otherwise. "is_literal" Returns true if this RDF node is a literal, false otherwise. "is_variable" Returns true if this RDF node is a variable, false otherwise. "as_string" Returns the node in a string form. "as_ntriples" Returns the node in a string form suitable for NTriples serialization. "sse" Returns the SSE serialization of the node. "equal ( $node )" Returns true if the two nodes are equal, false otherwise. "compare ( $node_a, $node_b )" Returns -1, 0, or 1 if $node_a sorts less than, equal to, or greater than $node_b in the defined SPARQL ordering, respectively. This function may be used as the function argument to "<sort">. "from_sse ( $string, $context )" Parses the supplied SSE-encoded string and returns a RDF::Trine::Node object. BUGS
Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. AUTHOR
Gregory Todd Williams "<gwilliams@cpan.org>" COPYRIGHT
Copyright (c) 2006-2012 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-06-29 RDF::Trine::Node(3pm)
All times are GMT -4. The time now is 08:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy