Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Extract common data out of multiple files Post 302748023 by macmath on Monday 24th of December 2012 06:23:30 AM
Old 12-24-2012
Extract common data out of multiple files

I am trying to extract common list of Organisms from different files
For example I took 3 files and showed expected result. In real I have more than 1000 files. I am aware about the useful use of awk and grep but unaware in depth so need guidance regarding it.

I want to use awk/ grep/ cut/ perl/ python to get the needful result.
File A:
Pseudomonas stutzeri A1501
Pseudomonas fragi A22
Pseudomonas fluorescens A506
Aeromonas caviae Ae398
Rickettsiella grylli
Aeromonas veronii AMC34
File B:
Rickettsiella grylli
Pseudomonas fulva 12-X
Pseudomonas extremaustralis 14-3 substr. 14-3b
Aeromonas caviae Ae398
Gallaecimonas xiamenensis 3-C-1
Pseudomonas stutzeri A1501
File C:
Pseudomonas extremaustralis
Pseudomonas fulva 12-X
Pseudomonas extremaustralis 14-3 substr. 14-3b
Aeromonas caviae Ae398
Rickettsiella grylli
Pseudomonas stutzeri A1501
Expected Result file : Common organism
Aeromonas caviae Ae398
Pseudomonas stutzeri A1501
Rickettsiella grylli
Hoping for your suggestions and support.
Thank you in advance
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to rename multiple files with a common suffix

Hi, There are multiple files like file1_11 file2_11 file3_11.....and so on. How to rename them such tht the suffix _11 is removed and they become file1, file2, file3. Any help is appreciated. Regards er_ashu (1 Reply)
Discussion started by: er_ashu
1 Replies

2. Shell Programming and Scripting

Get common lines from multiple files

FileA chr1 31237964 NP_001018494.1 PUM1 M340L chr1 31237964 NP_055491.1 PUM1 M340L chr1 33251518 NP_037543.1 AK2 H191D chr1 33251518 NP_001616.1 AK2 H191D chr1 57027345 NP_001004303.2 C1orf168 P270S FileB chr1 ... (9 Replies)
Discussion started by: genehunter
9 Replies

3. UNIX for Dummies Questions & Answers

AWK, extract data from multiple files

Hi, I'm using AWK to try to extract data from multiple files (*.txt). The script should look for a flag that occurs at a specific position in each file and it should return the data to the right of that flag. I should end up with one line for each file, each containing 3 columns:... (8 Replies)
Discussion started by: Liverpaul09
8 Replies

4. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

5. Shell Programming and Scripting

Extract common words from two/more csv files

I have two (or more, to make it generic) csv files. Each line contains words separated by comma. None of words have any space. The number of words per line is not fixed. Some may have one, and some may have 12... The number of lines per file is also not fixed. What I need is to find common words... (1 Reply)
Discussion started by: nick2011
1 Replies

6. Shell Programming and Scripting

Find common lines between multiple files

Hello everyone A few years Ago the user radoulov posted a fancy solution for a problem, which was about finding common lines (gene variation names) between multiple samples (files). The code was: awk 'END { for (R in rec) { n = split(rec, t, "/") if (n > 1) dup = dup ?... (5 Replies)
Discussion started by: bibb
5 Replies

7. Shell Programming and Scripting

Compare multiple files, and extract items that are common to ALL files only

I have this code awk 'NR==FNR{a=$1;next} a' file1 file2 which does what I need it to do, but for only two files. I want to make it so that I can have multiple files (for example 30) and the code will return only the items that are in every single one of those files and ignore the ones... (7 Replies)
Discussion started by: castrojc
7 Replies

8. Shell Programming and Scripting

Extract data in tabular format from multiple files

Hi, I have directory with multiple files from which i need to extract portion of specif lines and insert it in a new file, the new file will contain a separate columns for each file data. Example: I need to extract Value_1 & Value_3 from all files and insert in output file as below: ... (2 Replies)
Discussion started by: belalr
2 Replies

9. Shell Programming and Scripting

Get both common and missing values from multiple files

Hi, I have 5 files with two columns. I need to merge all the 5 files based on column 1. If any of them are missing then corresponding 2nd column should be substituted by missing value. I know hoe to do this for 2 files. but how can I implement for 5 files. I tried this based on 5 files but it... (2 Replies)
Discussion started by: Diya123
2 Replies

10. Shell Programming and Scripting

Merge multiple files with common header

Hi all, Say i have multiple files x1 x2 x3 x4, all with common header (date, time, year, age),, How can I merge them to one singe file "X" in shell scripting Thanks for your suggestions. (2 Replies)
Discussion started by: msarguru
2 Replies
ExtUtils::Constant(3pm) 				 Perl Programmers Reference Guide				   ExtUtils::Constant(3pm)

NAME
ExtUtils::Constant - generate XS code to import C header constants SYNOPSIS
use ExtUtils::Constant qw (WriteConstants); WriteConstants( NAME => 'Foo', NAMES => [qw(FOO BAR BAZ)], ); # Generates wrapper code to make the values of the constants FOO BAR BAZ # available to perl DESCRIPTION
ExtUtils::Constant facilitates generating C and XS wrapper code to allow perl modules to AUTOLOAD constants defined in C library header files. It is principally used by the "h2xs" utility, on which this code is based. It doesn't contain the routines to scan header files to extract these constants. USAGE
Generally one only needs to call the "WriteConstants" function, and then #include "const-c.inc" in the C section of "Foo.xs" INCLUDE: const-xs.inc in the XS section of "Foo.xs". For greater flexibility use "constant_types()", "C_constant" and "XS_constant", with which "WriteConstants" is implemented. Currently this module understands the following types. h2xs may only know a subset. The sizes of the numeric types are chosen by the "Configure" script at compile time. IV signed integer, at least 32 bits. UV unsigned integer, the same size as IV NV floating point type, probably "double", possibly "long double" PV NUL terminated string, length will be determined with "strlen" PVN A fixed length thing, given as a [pointer, length] pair. If you know the length of a string at compile time you may use this instead of PV SV A mortal SV. YES Truth. ("PL_sv_yes") The value is not needed (and ignored). NO Defined Falsehood. ("PL_sv_no") The value is not needed (and ignored). UNDEF "undef". The value of the macro is not needed. FUNCTIONS
constant_types A function returning a single scalar with "#define" definitions for the constants used internally between the generated C and XS functions. XS_constant PACKAGE, TYPES, XS_SUBNAME, C_SUBNAME A function to generate the XS code to implement the perl subroutine PACKAGE::constant used by PACKAGE::AUTOLOAD to load constants. This XS code is a wrapper around a C subroutine usually generated by "C_constant", and usually named "constant". TYPES should be given either as a comma separated list of types that the C subroutine "constant" will generate or as a reference to a hash. It should be the same list of types as "C_constant" was given. [Otherwise "XS_constant" and "C_constant" may have different ideas about the number of parameters passed to the C function "constant"] You can call the perl visible subroutine something other than "constant" if you give the parameter XS_SUBNAME. The C subroutine it calls defaults to the name of the perl visible subroutine, unless you give the parameter C_SUBNAME. autoload PACKAGE, VERSION, AUTOLOADER A function to generate the AUTOLOAD subroutine for the module PACKAGE VERSION is the perl version the code should be backwards compatible with. It defaults to the version of perl running the subroutine. If AUTOLOADER is true, the AUTOLOAD subroutine falls back on AutoLoader::AUTOLOAD for all names that the constant() routine doesn't recognise. WriteMakefileSnippet WriteMakefileSnippet ATTRIBUTE => VALUE [, ...] A function to generate perl code for Makefile.PL that will regenerate the constant subroutines. Parameters are named as passed to "WriteConstants", with the addition of "INDENT" to specify the number of leading spaces (default 2). Currently only "INDENT", "NAME", "DEFAULT_TYPE", "NAMES", "C_FILE" and "XS_FILE" are recognised. WriteConstants ATTRIBUTE => VALUE [, ...] Writes a file of C code and a file of XS code which you should "#include" and "INCLUDE" in the C and XS sections respectively of your module's XS code. You probably want to do this in your "Makefile.PL", so that you can easily edit the list of constants without touching the rest of your module. The attributes supported are NAME Name of the module. This must be specified DEFAULT_TYPE The default type for the constants. If not specified "IV" is assumed. BREAKOUT_AT The names of the constants are grouped by length. Generate child subroutines for each group with this number or more names in. NAMES An array of constants' names, either scalars containing names, or hashrefs as detailed in "C_constant". PROXYSUBS If true, uses proxy subs. See ExtUtils::Constant::ProxySubs. C_FH A filehandle to write the C code to. If not given, then C_FILE is opened for writing. C_FILE The name of the file to write containing the C code. The default is "const-c.inc". The "-" in the name ensures that the file can't be mistaken for anything related to a legitimate perl package name, and not naming the file ".c" avoids having to override Makefile.PL's ".xs" to ".c" rules. XS_FH A filehandle to write the XS code to. If not given, then XS_FILE is opened for writing. XS_FILE The name of the file to write containing the XS code. The default is "const-xs.inc". XS_SUBNAME The perl visible name of the XS subroutine generated which will return the constants. The default is "constant". C_SUBNAME The name of the C subroutine generated which will return the constants. The default is XS_SUBNAME. Child subroutines have "_" and the name length appended, so constants with 10 character names would be in "constant_10" with the default XS_SUBNAME. AUTHOR
Nicholas Clark <nick@ccl4.org> based on the code in "h2xs" by Larry Wall and others perl v5.16.3 2013-03-04 ExtUtils::Constant(3pm)
All times are GMT -4. The time now is 10:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy