Sponsored Content
Top Forums Shell Programming and Scripting Extract a pattern from multiple lines in a file Post 302753541 by Viernes on Wednesday 9th of January 2013 02:29:41 AM
Old 01-09-2013
Extract a pattern from multiple lines in a file

I have a file that has some lines starts with *
I want to get these lines, then get the word between "diac" and "lex".

ex.
file:
Code:
;;WORD AlAx
*0.942490 diac:Al>ax lex:>ax_1 bw:Al/DET+>ax/NOUN+ gloss:brother pos:noun prc3:0 prc2:0 prc1:0 prc0:Al_det per:na asp:na vox:na mod:na gen:m num:s stt:d cas:u enc0:0 rat:y source:spvar stem:>ax stemcat:N0F
--------------
;;WORD gyr
*0.983117 diac:gayoru lex:gayor_1 bw:+gayor/NOUN+u/CASE_DEF_NOM gloss:not;other pos:noun prc3:0 prc2:0 prc1:0 prc0:0 per:na asp:na vox:na mod:na gen:m num:s stt:c cas:n enc0:0 rat:y source:lex stem:gayor stemcat:N

Desired output:
Code:
Al>ax
gayoru


I am not sure if I should use sed or grep. Have been trying for a while, with this command:
Code:
grep -A 3 -o ':.* lex:' boo

I get:
Code:
:Al>ax lex:

Thank you in advance!
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract x lines after a pattern - place each result in separate file

Hi all, I have many files that have 1 or more occurrences of the information I want. There are two distinct sets of information. I want get this info and place each occurrence in its own file. The 3 lines before one set are this grid 00 01 02 16 17 18 **40 lines of code I want to... (5 Replies)
Discussion started by: gobi
5 Replies

2. UNIX for Dummies Questions & Answers

Help please, extract multiple lines from a text file

Hi all, I need to extract lines between the lines 'RD' and 'QA' from a text file (following). there are more that one of such pattern in the file and I need to extract all of them. however, the number of lines between them is varied in the file. Therefore, I can not just use 'grep -A' command.... (6 Replies)
Discussion started by: johnshembb
6 Replies

3. Shell Programming and Scripting

Extract strings from multiple lines into one file -

input file Desired csv output gc_type, date/time, milli secs af, Mar 17 13:09:04 2011, 144.596 af, Mar 20 00:37:37 2011, 144.242 af, ar 20 21:30:59 2011, 108.518 Hi All, Any help in acheiving the above would be appreciated. I would like to parse through lines within one file and... (5 Replies)
Discussion started by: satish.vampire
5 Replies

4. Shell Programming and Scripting

Extract strings from multiple lines into one csv file

Hi all, Please go through my requirement. I have a log file in the location /opt/WebSphere61/AppServer/profiles/EMQbatchprofile/logs/EMQbatch This file contains the follwing pattern data <af type="tenured" id="42" timestamp="May 14 13:44:13 2011" intervalms="955.624"> <minimum... (8 Replies)
Discussion started by: satish.vampire
8 Replies

5. UNIX for Dummies Questions & Answers

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... (1 Reply)
Discussion started by: Oyster
1 Replies

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

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
ml-ulex(1)						      General Commands Manual							ml-ulex(1)

NAME
ml-ulex - lexer generator for Standard ML SYNOPSIS
ml-ulex [--dot] [--dump] [--match] [--ml-lex-mode] [--minimize] file DESCRIPTION
This manual page documents briefly the ml-ulex command. This manual page was written for the Debian distribution because the original pro- gram does not have a manual page. The ml-ulex script is part of the SML/NJ CM (Compilation and Library Manager) that is used to generate standalone programs. OPTIONS
A summary of some of the options is included below. --dot Generate DOT output (for graphviz). --match Enter interactive matching mode. --ml-lex-mode Operate in ml-lex compatibility mode. SEE ALSO
sml(1), ml-antlr(1), ml-lex(1), ml-yacc(1). The programs are documented fully by CM: The SML/NJ Compilation and Library Manager, User Manual, Matthias Blume, which is available via <http://cm.bell-labs.com/cm/cs/what/smlnj/doc/CM/new.pdf>. AUTHOR
This manual page was written by Daniel Moerner <dmoerner@gmail.com>, for the Debian GNU/Linux system (but may be used by others). September 4, 2009 ml-ulex(1)
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy