String match, with perl command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String match, with perl command
# 1  
Old 02-06-2014
String match, with perl command

Code:
 cat clinvar_00-latest.vcf | perl -aF/\\t/ -lne '/CLNSRCID=(\d+)/ and print join("\t",@F[0,1,1,3,4],$1)'  > OMIM.txt

The above code finds the text CLNSRCID=, but only outputs those records in which there is a numerical value only.

For example, the first match is CLNSRCID=103320.0001 in line 4 of the input (clinvar_00-latest.vcf), so the out below, (which is correct), is:

1 985955 985955 G C 103320

However, line 29051 is missed (presimaably because of the text) CLNSRCID=NBK1124|176876.0003

(desired output)
12 112915523 112915523 A G NBK1124|176876

Can the code be modified so these lines are included? I have included the input (clinvar_00-latest.vcf) and the output as of now (OMIM.txt). Thanks.

Last edited by joeyg; 02-06-2014 at 12:14 PM.. Reason: added to title
# 2  
Old 02-07-2014
Code:
perl -aF/\\t/ -lne '/CLNSRCID=((?:\w+?\|)*\d+)/ and print join("\t",@F[0,1,1,3,4],$1)' clinvar_00-latest.vcf  > OMIM.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match exact String with sed command

I have a workaround to the problem i m posting, however if someone wants to look at my query and respond ... i will appreciate. This is in reference to this thread -> https://www.unix.com/shell-programming-and-scripting/267630-extract-between-two-exact-matched-strings.html I have data.txt as... (11 Replies)
Discussion started by: mohtashims
11 Replies

2. Shell Programming and Scripting

Grep command to search a regular expression in a line an only print the string after the match

Hello, one step in a shell script i am writing, involves Grep command to search a regular expression in a line an only print the string after the match an example line is below /logs/GRAS/LGT/applogs/lgt-2016-08-24/2016-08-24.8.log.zip:2016-08-24 19:12:48,602 ERROR... (9 Replies)
Discussion started by: Ramneekgupta91
9 Replies

3. Shell Programming and Scripting

awk : match the string and string with the quotes :

Hi all, Here is the data file: - want to match only lan3 in the output . - not lan3:1 file : OPERATING_SYSTEM=HP-UX LOOPBACK_ADDRESS=127.0.0.1 INTERFACE_NAME="lan3" IP_ADDRESS="10.53.52.241" SUBNET_MASK="255.255.255.192" BROADCAST_ADDRESS="" INTERFACE_STATE=""... (2 Replies)
Discussion started by: rveri
2 Replies

4. Shell Programming and Scripting

perl regex string match issue..kindly help

i have a script in which i need to skip comments, and i am able to achieve it partially... IN text file: {**************************** {test : test...test } Script: while (<$fh>) { push ( @data, $_); } if ( $data =~ m/(^{\*+$)/ ){ } With the above match i am... (5 Replies)
Discussion started by: avskrm
5 Replies

5. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

6. Shell Programming and Scripting

Perl : how to match non-empty string that has no spaces

Hi Everyone, I am looking for neat way to grep a non-empty string that basically contains a hostname, which might be in FWDN form or without the domain, for example: hostname.internal.domainname.net The file I am parsing contains blan lines (^$) and also series of "-" which in other places... (2 Replies)
Discussion started by: togr
2 Replies

7. Shell Programming and Scripting

Match hex value in string (Perl)

I am trying to match a character return from a website so that I can replace it. It is the '...' character (didnt even know it existed initially). The character apparently has the hex value of 2026, but in the script, attempting to substitute regular 3 periods is not working. What am I... (2 Replies)
Discussion started by: Guyverix
2 Replies

8. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

9. Shell Programming and Scripting

pattern match url in string / PERL

Am trying to remove urls from text strings in PERL. I have the following but it does not seem to work: $remarks =~ s/www\.\s+\.com//gi; In English, I want to look for www. then I want to delete the www. and everything after it until I hit a space (but not including the space). It's not... (2 Replies)
Discussion started by: mrealty
2 Replies

10. Shell Programming and Scripting

Perl: Better way to match string within a string

Hi, I'm trying to get one field out of many as follows: A string of multiple fields separated with "/" characters: "/ab=12/cd=34/12=ab/34=cd/ef=pick-this.one/gh=blah/ij=something/" I want to pick up the field "ef=pick-this.one" which has no regular pattern except it starts with "ef=xxxx"... (3 Replies)
Discussion started by: Juha
3 Replies
Login or Register to Ask a Question