Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd Post 303032265 by RudiC on Thursday 14th of March 2019 10:10:58 AM
Old 03-14-2019
Now, this problem has been solved umpteen times in these fora. Try searching relevant threads and adapting the given solutions. You may start with the links at this page's lower left under "More UNIX and Linux Forum Topics You Might Find Helpful".
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

two files.say a and b.both have long columns.i wanna match the column fron 1st file w

ex: a file has : 122323 123456456 125656879 678989965t635 234323432 b has : this is finance no. this is phone no this is extn ajkdgag idjsidj i want the o/p as: 122323 his is finance no. 123456456 this is phone no 123456456 ... (4 Replies)
Discussion started by: TRUPTI
4 Replies

2. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

3. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

4. Shell Programming and Scripting

Match a line in File 1 with Column in File 2 and print whole line in file 2 when matched

Hi Experts, I am very new to scripting and have a prb since few days and it is urgent to solve so much appreciated if u help me. i have 2 files file1.txt 9647810043118 9647810043126 9647810043155 9647810043161 9647810043166 9647810043185 9647810043200 9647810043203 9647810043250... (22 Replies)
Discussion started by: mustafa.abdulsa
22 Replies

5. Shell Programming and Scripting

comparing column of two different files and print the column from in order of 2nd file

Hi friends, My file is like: Second file is : I need to print the rows present in file one, but in order present in second file....I used while read gh;do awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile done < secondfile but the output I am... (14 Replies)
Discussion started by: CAch
14 Replies

6. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

7. Shell Programming and Scripting

Grep/Awk on 1st 2 Letters in 2nd Column of File

Hi everyone. I need to change a script (ksh) so that it will grep on the 1st 2 letters in the second column of a 5 column file such as this one: 192.168.1.1 CAXY0_123 10ABFL000001 # Comment 192.168.1.2 CAYZ0_123 10ABTX000002 # Comment 192.168.2.1 FLXY0_123 11ABCA000001 ... (4 Replies)
Discussion started by: TheNovice
4 Replies

8. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

9. Linux

Print the 1st column and the value in 2nd or 3rd column if that is different from the values in 1st

I have file that looks like this, DIP-17571N|refseq:NP_651151 DIP-17460N|refseq:NP_511165|uniprotkb:P45890 DIP-17571N|refseq:NP_651151 DIP-19241N|refseq:NP_524261 DIP-19241N|refseq:NP_524261 DIP-17151N|refseq:NP_524316|uniprotkb:O16797 DIP-19588N|refseq:NP_731165 ... (2 Replies)
Discussion started by: Syeda Sumayya
2 Replies

10. Shell Programming and Scripting

Input file needs to match a column and print the entire line

I have a file with class c IP addresses that I need to match to a column and print the matching lines of another file. I started playing with grep -if file01.out file02.out but I am stuck as to how to match it to a column and print the matching lines; cat file01.out 10.150.140... (5 Replies)
Discussion started by: lewk
5 Replies
PPI::Find(3)						User Contributed Perl Documentation					      PPI::Find(3)

NAME
PPI::Find - Object version of the Element->find method SYNOPSIS
# Create the Find object my $Find = PPI::Find->new( &wanted ); # Return all matching Elements as a list my @found = $Find->in( $Document ); # Can we find any matching Elements if ( $Find->any_matches($Document) ) { print "Found at least one matching Element"; } # Use the object as an iterator $Find->start($Document) or die "Failed to execute search"; while ( my $token = $Find->match ) { ... } DESCRIPTION
PPI::Find is the primary PDOM searching class in the core PPI package. History It became quite obvious during the development of PPI that many of the modules that would be built on top of it were going to need large numbers of saved, storable or easily creatable search objects that could be reused a number of times. Although the internal ->find method provides a basic ability to search, it is by no means thorough. PPI::Find attempts to resolve this problem. Structure and Style PPI::Find provides a similar API to the popular File::Find::Rule module for file searching, but without the ability to assemble queries. The implementation of a separate PPI::Find::Rule sub-class that does provide this ability is left as an exercise for the reader. The &wanted function At the core of each PPI::Find object is a "wanted" function that is passed a number of arguments and returns a value which controls the flow of the search. As the search executes, each Element will be passed to the wanted function in depth-first order. It will be provided with two arguments. The current Element to test as $_[0], and the top-level Element of the search as $_[1]. The &wanted function is expected to return 1 (positive) if the Element matches the condition, 0 (false) if it does not, and undef (undefined) if the condition does not match, and the Find search should not descend to any of the current Element's children. Errors should be reported from the &wanted function via die, which will be caught by the Find object and returned as an error. METHODS
new &wanted The "new" constructor takes a single argument of the &wanted function, as described above and creates a new search. Returns a new PPI::Find object, or "undef" if not passed a CODE reference. clone The "clone" method creates another instance of the same Find object. The cloning is done safely, so if your existing Find object is in the middle of an iteration, the cloned Find object will not also be in the iteration and can be safely used independently. Returns a duplicate PPI::Find object. in $Document [, array_ref => 1 ] The "in" method starts and completes a full run of the search. It takes as argument a single PPI::Element object which will serve as the top of the search process. Returns a list of PPI::Element objects that match the condition described by the &wanted function, or the null list on error. You should check the ->errstr method for any errors if you are returned the null list, which may also mean simply that no Elements were found that matched the condition. Because of this need to explicitly check for errors, an alternative return value mechanism is provide. If you pass the "array_ref =" 1> parameter to the method, it will return the list of matched Elements as a reference to an ARRAY. The method will return false if no elements were matched, or "undef" on error. The ->errstr method can still be used to get the error message as normal. start $Element The "start" method lets the Find object act as an iterator. The method is passed the parent PPI::Element object as for the "in" method, but does not accept any parameters. To simplify error handling, the entire search is done at once, with the results cached and provided as-requested. Returns true if the search completes, and false on error. match The "match" method returns the next matching Element in the iteration. Returns a PPI::Element object, or "undef" if there are no remaining Elements to be returned. finish The "finish" method provides a mechanism to end iteration if you wish to stop the iteration prematurely. It resets the Find object and allows it to be safely reused. A Find object will be automatically finished when "match" returns false. This means you should only need to call "finnish" when you stop iterating early. You may safely call this method even when not iterating and it will return without failure. Always returns true errstr The "errstr" method returns the error messages when a given PPI::Find object fails any action. Returns a string, or "undef" if there is no error. TO DO
- Implement the PPI::Find::Rule class SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2011-02-25 PPI::Find(3)
All times are GMT -4. The time now is 06:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy