Sponsored Content
Top Forums Shell Programming and Scripting Perl to extract values and print at end of each line Post 303035235 by k_manimuthu on Friday 17th of May 2019 02:59:55 AM
Old 05-17-2019
Your code regex part doesn't have reference for GT:PL value and need to modify the regex part.
Try the below code and you can add more regex based on your needs.

Code:
 perl -plane ' BEGIN{ %h = qw(0/0 hom 0/1 het 1/1 hom 1/2 het 2/2 hom) } /^[^#].*AF1=(\d+\.?\d*);.*GT:PL\s*([^:]+):/ and $_ .= join "\t", ("",  sprintf("%1.2f",$1), $h{$2}, int($F[5]/33+0.5))' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract a particular start and end pattern from a line

hi In the foll example the whole text in a single line.... i want to extract text from IPTel to RTCPBase.h. want to use this acrooss the whole file Updated: IPTel\platform\core\include\RTCPBase.h \main\MWS2051_Sablime_Int\1... (7 Replies)
Discussion started by: manish205
7 Replies

2. UNIX for Dummies Questions & Answers

Using sed to extract a substring at end of line

This is the line that I am using: sed 's/^*\({3}*$\)/\1 /' <test.txt >results.txt and suppose that test.txt contains the following lines: http://www.example.com/200904/AUS.txt http://www.example.com/200903/_RUS.txt http://www.example.com/200902/.FRA.txt What I expected to see in results.txt... (6 Replies)
Discussion started by: figaro
6 Replies

3. Shell Programming and Scripting

extract values from column with Perl

Hi everybody I have some problems with PERL programming. I have a file with two columns, both with numeric values. I have to extract the values > 50 from the 2nd columns and sum them among them. The I have to sum the respective values in the first column on the same line and, at the end, I... (6 Replies)
Discussion started by: m_elena
6 Replies

4. Shell Programming and Scripting

Extract X words from end of line, minus last keynumber X

The file contains one line of text followed by a number. I want to take the number X at the end, take it out and display the last X words. X is the key telling me how many words from the end that I want and X will always be less than the number of words, so no problem there. Example input and... (4 Replies)
Discussion started by: fubaya
4 Replies

5. Shell Programming and Scripting

Print required values at end of the file by using AWK

I am looking help in awk, quick overview. we will get feed from external system . The input file looks like below. Detail Id Info Id Order Id STATUS Status Date FileDetail 99127942 819718 CMOG223481502 PR 04-17-2011 06:01:34PM... (7 Replies)
Discussion started by: dvrbabu
7 Replies

6. Shell Programming and Scripting

End of each line count the values in the file

Hi, How to find the end of character in the file. My requirement should be as below.1 is repeating 1 time ,2 is repeating 3 times... type 1: 1 type 2: 3 type 3: 2 9f680177|20077337258|0|0|0|1000004647916|1 9f680177|20077337258|0|0|0|1000004647916|2 9f680177 20077337258 0 0 0... (5 Replies)
Discussion started by: bmk
5 Replies

7. Shell Programming and Scripting

Extract key words and print their values

Input file (HTTP request log file): GET... (2 Replies)
Discussion started by: buptwy
2 Replies

8. Shell Programming and Scripting

Extract values from Perl variable

Hi Guys, I am stuck in a problem. I have a variable in Perl script which has value for example X=a-b-c; Now, I want to extract a b c separately into different 3 variables. I know this can be done in shell using awk but Perl behaves a bit different. Can anybody help me on this please?... (3 Replies)
Discussion started by: prashant2507198
3 Replies

9. Shell Programming and Scripting

How to extract text from STRING to end of line?

Hi I have a very large data file with several hundred columns and millions of lines. The important data is in the last set of columns with variable numbers of tab delimited fields in front of it on each line. Im currently trying sed to get the data out - I want anything beetween :RES and... (4 Replies)
Discussion started by: Manchesterpaul
4 Replies

10. Shell Programming and Scripting

Extract values from a specific column to the end

Hello friends, I have a text file with many columns (no. columns vary from row to row) separated by space. I need to collect all the values from 18th column to the end from each line and group them as pairs and then numbering like below.. 1. 18th-col-value 19th-col-value 2. 20th-col-value ... (5 Replies)
Discussion started by: prvnrk
5 Replies
EXTRACT(1)						      General Commands Manual							EXTRACT(1)

NAME
extract - determine meta-information about a file SYNOPSIS
extract [ -bghLnvV ] [ -H hash-algorithm ] [ -i ] [ -l library ] [ -p type ] [ -x type ] file ... DESCRIPTION
This manual page documents version 0.6.0 of the extract command. extract tests each file specified in the argument list in an attempt to infer meta-information from it. Each file is subjected to the meta-data extraction libraries from libextractor. libextractor classifies meta-information (also referred to as keywords) into types. A list of all types can be obtained with the -L option. OPTIONS
-b Display the output in BiBTeX format. -g Use grep-friendly output (all keywords on a single line for each file). Use the verbose option to print the filename first, fol- lowed by the keywords. Use the verbose option twice to also display the keyword types. This option will not print keyword types or non-textual metadata. -h Print a brief summary of the options. -i Run plugins in-process (for debugging). By default, each plugin is run in its own process. -l libraries Use the specified libraries to extract keywords. The general format of libraries is .I [[-]LIBRARYNAME[:[-]LIBRARYNAME]*] where LIBRARYNAME is a libextractor compatible library and typically of the form .Ijpeg. The minus before the libraryname indicates that this library should be removed from the existing list. To run only a few selected plugins, use -l in combination with -n. -L Print a list of all known keyword types. -n Do not use the default set of extractors (typically all standard extractors, currently mp3, ogg, jpg, gif, png, tiff, real, html, pdf and mime-types), use only the extractors specified with the .B -l option. -p type Print only the keywords matching the specified type. By default, all keywords that are found and not removed as duplicates are printed. -v Print the version number and exit. -V Be verbose. This option can be specified multiple times to increase verbosity further. -x type Exclude keywords of the specified type from the output. By default, all keywords that are found and not removed as duplicates are printed. SEE ALSO
libextractor(3) - description of the libextractor library EXAMPLES
$ extract test/test.jpg comment - (C) 2001 by Christian Grothoff, using gimp 1.2 1 mimetype - image/jpeg $ extract -V -x comment test/test.jpg Keywords for file test/test.jpg: mimetype - image/jpeg $ extract -p comment test/test.jpg comment - (C) 2001 by Christian Grothoff, using gimp 1.2 1 $ extract -nV -l png.so -p comment test/test.jpg test/test.png Keywords for file test/test.jpg: Keywords for file test/test.png: comment - Testing keyword extraction LEGAL NOTICE
libextractor and the extract tool are released under the GPL. libextractor is a GNU package. BUGS
A couple of file-formats (on the order of 10^3) are not recognized... AUTHORS
extract was originally written by Christian Grothoff <christian@grothoff.org> and Vidyut Samanta <vids@cs.ucla.edu>. Use <libextrac- tor@gnu.org> to contact the current maintainer(s). AVAILABILITY
You can obtain the original author's latest version from http://www.gnu.org/software/libextractor/ libextractor 0.6.0 Dec 20, 2009 EXTRACT(1)
All times are GMT -4. The time now is 04:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy