Sponsored Content
Top Forums Shell Programming and Scripting Extract lines that match a pattern Post 302859839 by Kashyap on Friday 4th of October 2013 03:39:49 AM
Old 10-04-2013
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,

Code:
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, revision 2 (99%)
    Installed XYZ XYZA Image, API 18, revision 2

This part of the file repeats through out the file some "n" times.
The problem in front of me is i need to extract the bold line that repeats n times in the file and put them into another file.

I tried this piece of code but in vain.

Code:
grep -o "Installed*" filename > destfile

This actually matches the pattern and puts the lines after the required line.

Please let me know where i am wrong.

Thanks.
 

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

counting lines that match pattern

I have a file of 1.3 millions lines. some are with the same word twice on the line, some line have two diffrent words. each line has two words, one in brackets. example: foo (foo) bar (bar) thae (awvd) beladf (vswvw) I am sure this can be done with one line of... (6 Replies)
Discussion started by: robsonde
6 Replies

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

7. Shell Programming and Scripting

Print lines that do not match the pattern

I need to print the lines that do not match a pattern. I tried using grep -v and sed -n '/pattern/!p', but both of them are not working as I am passing the pattern as variable and it can be null some times. Example ........ abcd...... .........abcd...... .........abcd......... (4 Replies)
Discussion started by: sunny1234
4 Replies

8. Shell Programming and Scripting

Printing next 6 lines from of pattern match

Hi, i have a big file having many opcodes. if (opcode="01110000000100000000" ) then --fadd result.opcode := "01110000000100000000"; result.s0 := '1'; result.s1 := '1'; result.s2 := '0'; result.inst := '0'; result.scalar := '1';... (7 Replies)
Discussion started by: twistedpair
7 Replies

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

10. UNIX for Beginners Questions & Answers

Help with pattern match and Extract

Hi All, I am having a file like below . Basically when SB comes in the text with B. I have to take the word till SB. When there only B I should take take till B. Tried for cut it by demilter but not able to build the logic SB- CD B_RESTO SB_RESTO CRYSTALS BOILERS -->There SB and B so I... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies
Image::ExifTool::BuildTagLookup(3pm)			User Contributed Perl Documentation		      Image::ExifTool::BuildTagLookup(3pm)

NAME
Image::ExifTool::BuildTagLookup - Build ExifTool tag lookup tables DESCRIPTION
This module is used to generate the tag lookup tables in Image::ExifTool::TagLookup.pm and tag name documentation in Image::ExifTool::TagNames.pod, as well as HTML tag name documentation. It is used before each new ExifTool release to update the lookup tables and documentation, but it is not used otherwise. SYNOPSIS
use Image::ExifTool::BuildTagLookup; $builder = new Image::ExifTool::BuildTagLookup; $ok = $builder->WriteTagLookup('lib/Image/ExifTool/TagLookup.pm'); $ok = $builder->WriteTagNames('lib/Image/ExifTool/TagNames.pod','html'); MEMBER VARIABLES
PRESERVE_DATE Flag to preserve "Last revised" date in HTML files. Set before calling WriteTagNames(). COUNT Reference to hash containing counting statistics. Keys are the descriptions, and values are the numerical counts. Valid after BuildTagLookup object is created, but additional statistics are added by WriteTagNames(). AUTHOR
Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Image::ExifTool(3pm), Image::ExifTool::TagLookup(3pm), Image::ExifTool::TagNames(3pm) perl v5.12.4 2011-05-26 Image::ExifTool::BuildTagLookup(3pm)
All times are GMT -4. The time now is 12:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy