Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Help with pattern match and Extract Post 303025919 by Peasant on Thursday 15th of November 2018 06:35:15 AM
Old 11-15-2018
I must add that this user never posts his attempts.
He/she just requires someone else to code instead of him.

The search option confirms this.
This is just rude.

Dear arunkumar_mca

Various fairly complex awk solutions provided in past should be start to learn parsing text in unix environments.
Give it shot, try to write something, then come here to improve / rewrite your code using advice from folks here.

Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match first pattern first then extract second pattern match

My input file: <accession>Q91G55</accession> <name>043L_IIV6</name> <protein> <recommendedName> <location> <position position="294"/> </location> <fullName>Uncharacterized protein 043L</fullName> <accession>P18556</accession> <name>1106L_ASFB7</name> <protein> <recommendedName>... (5 Replies)
Discussion started by: patrick87
5 Replies

2. Shell Programming and Scripting

Extract data from records that match pattern

Hi Guys, I have a file as follows: a b c 1 2 3 4 pp gg gh hh 1 2 fm 3 4 g h i j k l m 1 2 3 4 d e f g h j i k l 1 2 3 f 3 4 r t y u i o p d p re 1 2 3 f 4 t y w e q w r a s p a 1 2 3 4 I am trying to extract all the 2's from each row. 2 is just an example... (6 Replies)
Discussion started by: npatwardhan
6 Replies

3. Shell Programming and Scripting

Need one liner to search pattern and print everything expect 6 lines from where pattern match made

i need to search for a pattern from a big file and print everything expect the next 6 lines from where the pattern match was made. (8 Replies)
Discussion started by: chidori
8 Replies

4. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

5. Shell Programming and Scripting

Pattern Match & Extract from a string

Hi, I have long string in 2nd field, as shown below: REF1 | CLESCLJSCSHSCSMSCSNSCSRSCUDSCUFSCU7SCV1SCWPSCXGPDBACAPA0DHDPDMESED6 REF2 | SBR4PCBFPCDRSCSCG3SCHEBSCKNSCKPSCLLSCMCZXTNPCVFPCV6P4KL0DMDSDSASEWG I have a group of fixed patterns which can occur in these long strings & only... (11 Replies)
Discussion started by: karumudi7
11 Replies

6. UNIX for Dummies Questions & Answers

Match Pattern after certain pattern and Print words next to Pattern

Hi experts , im new to Unix,AWK ,and im just not able to get this right. I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Discussion started by: 100bees
2 Replies

7. Shell Programming and Scripting

sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times. But it isnt working on the new linux box sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf its driving me nuts !! Is there something Im missing ? (7 Replies)
Discussion started by: popeye
7 Replies

8. Shell Programming and Scripting

Extract lines that match a pattern

Hi all, I got a file that contains the following content, Actually it is a part of the file content, Installing XYZ XYZA Image, API 18, revision 2 Unzipping XYZ XYZA Image, API 18, revision 2 (1%) Unzipping XYZ XYZA Image, API 18, revision 2 (96%) Unzipping XYZ XYZA Image, API 18,... (7 Replies)
Discussion started by: Kashyap
7 Replies

9. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

10. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

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
MakeMethods::Utility::TextBuilder(3pm)			User Contributed Perl Documentation		    MakeMethods::Utility::TextBuilder(3pm)

NAME
Class::MakeMethods::Utility::TextBuilder - Basic text substitutions SYNOPSIS
print text_builder( $base_text, @exprs ) DESCRIPTION
This module provides a single function, which implements a simple "text macro" mechanism for assembling templated text strings. $expanded_text = text_builder( $base_text, @exprs ) Returns a modified copy of $base_text using rules from the @exprs list. The @exprs list may contain any of the following: o A string, in which any '*' characters will be replaced by the base text. The interpolated string then replaces the base text. o A code-ref, which will be called with the base text as its only argument. The result of that call then replaces the base text. o A hash-ref, which will be added to the substitution hash used in the second pass, below. o An array-ref, containing additional expressions to be treated as above. After any initial string and code-ref rules have been applied, the hash of substitution rules are applied. The text will be searched for occurances of the keys of the substitution hash, which will be modified based on the corresponding value in the hash. If the substitution key ends with '{}', the search will also match a balanced block of braces, and that value will also be used in the substitution. The hash-ref may contain the following types of rules: o 'string' => 'string' Occurances of the first string are to be replaced by the second. o 'string' => code_ref Occurances of the string are to be replaced by the results of calling the subroutine with no arguments. o 'string{}' => 'string' Occurances of the first string and subsequent block of braces are replaced by a copy of the second string in which any '*' characters have first been replaced by the contents of the brace block. o 'string{}' => code_ref Occurances of the string and subsequent block of braces are replaced by the results of calling the subroutine with the contents of the brace block as its only argument. o 'string{}' => hash_ref Occurances of the string and subsequent block of braces are replaced by using the contents of the brace block as a key into the provided hash-ref. EXAMPLE
The following text and modification rules provides a skeleton for a collection letter: my $letter = "You owe us AMOUNT. Please pay up! " . "THREAT{SEVERITY}"; my @exprs = ( "Dear NAMEm *", "* -- The Management", { 'THREAT{}' => { 'good'=>'Please?', 'bad'=>'Or else!' } }, " DATE *", { 'DATE' => 'Tuesday, April 1, 2001' }, ); One might invoke this template by providing additional data for a given instance and calling the text_builder function: my $item = { 'NAME'=>'John', 'AMOUNT'=>'200 camels', 'SEVERITY'=>'bad' }; print text_builder( $letter, @exprs, $item ); The resulting output is shown below: Tuesday, April 1, 2001 Dear John, You owe us 200 camels. Please pay up! Or else! -- The Management SEE ALSO
See Class::MakeMethods for general information about this distribution. perl v5.10.1 2004-09-06 MakeMethods::Utility::TextBuilder(3pm)
All times are GMT -4. The time now is 08:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy