09-14-2011
print multiple lines from text file based on pattern list
I have a text file with a list of items/patterns:
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig12238
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig34624
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig56875
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig70306
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig71435
...
I would like to print those lines which match from a tab-delimited file containing many many more lines:
...
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60558 1086
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60559 641 95 14.038 ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60559 731
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60560 620 1406 245.247 ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60560 625
ConsensusfromCGX_alldays_trimmedcollapsedfilteredreadscontiglist(229095contigs)contig60561 609 208 36.771
...
Can grep process a pattern file? It seems as if it should, however, I have not had success. sed, awk? Please help. Thanks.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I have searched forum trying to find a solution to my problem, but could not find anything or I did not understand the examples....
I should say, I am very inexperienced with text processing.
I have a text file with approx 60k lines in it.
I need to merge lines based on the number... (8 Replies)
Discussion started by: Bertik
8 Replies
2. Shell Programming and Scripting
Hi all,
I am new to using awk and am quickly discovering what a powerful pattern-recognition tool it is. However, I have what seems like a fairly basic task that I just can't figure out how to perform in one line. I want awk to find and print all the lines in which one of multiple patterns (e.g.... (8 Replies)
Discussion started by: elgo4
8 Replies
3. Shell Programming and Scripting
Hi,
I have a text file (attached the sample). I have also, attached the way the way the files need to be split.
We get this file, that will either have 24 Jurisdictions, or will miss some and retain some.
Like in the attached sample file, there are only Jurisdictions 03,11,14,15, 20 and 30.... (3 Replies)
Discussion started by: ebsus
3 Replies
4. Shell Programming and Scripting
Hello Experts , require help . See below output:
File inputs
------------------------------------------
Server Host = mike
id rl images allocated last updated density
vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies
5. Shell Programming and Scripting
GM,
I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed.
I am assuming that sed, awk or even perl could do what I need.
I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies
6. Shell Programming and Scripting
In the awk below I am trying to print the entire line, along with the header row, if $2 is SNV or MNV or INDEL. If that condition is met or is true, and $3 is less than or equal to 0.05, then in $7 the sub pattern :GMAF= is found and the value after the = sign is checked. If that value is less than... (0 Replies)
Discussion started by: cmccabe
0 Replies
7. UNIX for Beginners Questions & Answers
Hi All-I am new to Unix , I need to write a script. Can someone help me with a requirement where I have list of files in a directory, I want to Merge the files if a pattern of string matches in filenames?
AAAL_555A_ORANGE1_F190404.TXT
AAAL_555A_ORANGE2_F190404.TXT
AAAL_555A_ORANGE3_F190404.TXT... (6 Replies)
Discussion started by: Shankar455
6 Replies
8. Shell Programming and Scripting
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
9. UNIX for Beginners Questions & Answers
Hi All,
i want to write a shell script read below file line by line and want to exclude the lines which contains empty value for MOUNTPOINT field.
i am using centos 7 Operating system.
want to read below file.
# cat /tmp/d5
NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root"... (4 Replies)
Discussion started by: balu1234
4 Replies
LEARN ABOUT CENTOS
glob_match
GLOB_MATCH(9) libata Core Internals GLOB_MATCH(9)
NAME
glob_match - match a text string against a glob-style pattern
SYNOPSIS
int glob_match(const char * text, const char * pattern);
ARGUMENTS
text
the string to be examined
pattern
the glob-style pattern to be matched against
DESCRIPTION
Either/both of text and pattern can be empty strings.
Match text against a glob-style pattern, with wildcards and simple sets:
? matches any single character. * matches any run of characters. [xyz] matches a single character from the set: x, y, or z. [a-d] matches a
single character from the range: a, b, c, or d. [a-d0-9] matches a single character from either range.
The special characters ?, [, -, or *, can be matched using a set, eg. [*] Behaviour with malformed patterns is undefined, though generally
reasonable.
SAMPLE PATTERNS
"SD1?", "SD1[0-5]", "*R0", "SD*1?[012]*xx"
This function uses one level of recursion per '*' in pattern. Since it calls _nothing_ else, and has _no_ explicit local variables, this
will not cause stack problems for any reasonable use here.
RETURNS
0 on match, 1 otherwise.
AUTHOR
Jeff Garzik
Author.
COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 GLOB_MATCH(9)