Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Searching for terms contained in 2 separate files Post 302598987 by Scrutinizer on Thursday 16th of February 2012 01:10:47 AM
Old 02-16-2012
I don't think you can do it that way. You'd probably need to use Unix' Swiss Army Knife:
Code:
awk ' f==1{A[$1]} 
      f==2{B[$1]} 
      f==3{if($2 in A) for(i=3;i<=NF;i++) if($i in B)print $1,$2,$i}
    ' FS='[ \t,]*' OFS=\| f=1 list1.tab f=2 list2.tab f=3 inventory

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to compare counts in two separate files

Hi all, what will be the code to compare count present in two seperate files for e.g file (a) contains counts 100 and file (b) contains records 90 since both these files have differnt count so it will display count didnt match and in case of success it display (5 Replies)
Discussion started by: jojo123
5 Replies

2. Shell Programming and Scripting

Searching across multiple files if pattern is available in all files searched

I have a list of pattern in a file, I want each of these pattern been searched from 4 files. I was wondering this can be done in SED / AWK. say my 4 files to be searched are > cat f1 abc/x(12) 1 abc/x 3 cde 2 zzz 3 fdf 4 > cat f2 fdf 4 cde 3 abc 2... (6 Replies)
Discussion started by: novice_man
6 Replies

3. Shell Programming and Scripting

Using bash to separate files files based on parts of a filename

Hey guys, Sorry for the basic question but I have a lot of files that I want to separate into groups based on filenames which I can then cat together. Eg I have: (a_b_c.txt) WB34_2_SLA8.txt WB34_1_SLA8.txt WB34_1_DB10.txt WB34_2_DB10.txt WB34_1_SLA8.txt WB34_2_SLA8.txt 77_1_SLA8.txt... (1 Reply)
Discussion started by: Breentax
1 Replies

4. Shell Programming and Scripting

Creating a Third File from Information Contained in Two Files

In advance, I appreciate any help or tips. I apologize for not providing examples of scripts I have already tried, the reason is that I am new to programming and do not really no where to start. I think this is possible with awk, but do not know how to go about learning how to write the script... (2 Replies)
Discussion started by: awc228
2 Replies

5. Shell Programming and Scripting

Grep multiple terms and output to individual files

Hi all, I'll like to search a list of tems in a huge file and then output each of the terms to individual files. I know I can use grep -f list main.file to search them but how can I split the output into individual files? Thank you. (6 Replies)
Discussion started by: ivpz
6 Replies

6. Web Development

Two separate domains - and files

Hi, I've been asked to 'troubleshoot' a webserver where two different TLDs are being served. Or to be more accurate, 'domain.com' and 'domain.fr'. So we have /var/www/domain.com /var/www/domain.fr And then for some reason, the httpd.conf file points to two different configuration files.... (1 Reply)
Discussion started by: davidm123SED
1 Replies

7. Shell Programming and Scripting

awk multiply values contained in 2 different files

Hi Everyone ! I have two files with the same configuration and I want to multiply corresponding values and write the result in a file. Let say 2 header lines and then lines of values (with not constant number of columns): more file1.txt --> BLABLABLA BLABLABLA 1 2 3 4 1 2 3 1 2 1... (7 Replies)
Discussion started by: Youm
7 Replies

8. UNIX for Dummies Questions & Answers

Grep -B used with -f? (Searching a file using a list of terms, output is lines before each match)

(1 Reply)
Discussion started by: Twinklefingers
1 Replies

9. Shell Programming and Scripting

Output in separate files

Hi all, i have the bash script for remote conection, for hosts in $(cat /list); do ssh user1@$hosts "hostname"; done execute hostname command by all hosts and show standar ouput, how i can send to file by each host in lists, so e.g. $cat list 10.0.0.1 10.0.0.2... (1 Reply)
Discussion started by: aav1307
1 Replies

10. Shell Programming and Scripting

Need separate vi files in shell

Input: I have input file below mentioned.Input file has Yahoo,gmail,yuimn etc..are websites and there are users listed under it. I have many other unique websites but i mentioned just few as below. For example: Yahoo is website and 123,fsfd are members of website "yahoo". See below input... (19 Replies)
Discussion started by: buzzme
19 Replies
MooseX::Storage::Util(3pm)				User Contributed Perl Documentation				MooseX::Storage::Util(3pm)

NAME
MooseX::Storage::Util - A MooseX::Storage Swiss Army chainsaw VERSION
version 0.45 DESCRIPTION
This module provides a set of tools, some sharp and focused, others more blunt and crude. But no matter what, they are useful bits to have around when dealing with MooseX::Storage code. METHODS
All the methods in this package are class methods and should be called appropriately. peek ($data, %options) This method will help you to verify that the serialized class you have gotten is what you expect it to be before you actually unfreeze/unpack it. The $data can be either a perl HASH ref or some kind of serialized data (JSON, YAML, etc.). The %options are as follows: format If this is left blank, we assume that $data is a plain perl HASH ref otherwise we attempt to inflate $data based on the value of this option. Currently only JSON and YAML are supported here. key The default is to try and extract the class name, but if you want to check another key in the data, you can set this option. It will return the value found in the key for you. Introspection meta TODO
Add more stuff to this module :) BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHORS
o Chris Prather <chris.prather@iinteractive.com> o Stevan Little <stevan.little@iinteractive.com> o XXXX XXX'XX (Yuval Kogman) <nothingmuch@woobling.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2013-12-21 MooseX::Storage::Util(3pm)
All times are GMT -4. The time now is 07:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy