Sponsored Content
Top Forums Shell Programming and Scripting Extract lines that match a pattern Post 302859945 by Kashyap on Friday 4th of October 2013 09:21:18 AM
Old 10-04-2013
Hi,
Mirwasim and pravin,

I rectifies my mistake. Both of your code works fine. Thanks for that.
Can you also let me how to solve this.??

The above grep command sends the output as required in a single.
this is how the output looks like,
Code:
Installed XYZ XYZA Image, API 18, revision 2 Installed XYZ XYZA Image, API 18, revision 2 Installed XYZ XYZA Image, API 18, revision 2 Installed XYZ XYZA Image, API 18, revision 2

Now i need the output to be in different lines along with line numbers like this,

1. Installed XYZ XYZA Image, API 18, revision 2
2. Installed XYZ XYZA Image, API 18, revision 2
3. Installed XYZ XYZA Image, API 18, revision 2
4. Installed XYZ XYZA Image, API 18, revision 2
and so on.

Please help me in achieving this, I tried doing this but in vain as i am a newbie to shell scripting.

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::Shortcuts(3pm) 			User Contributed Perl Documentation			   Image::ExifTool::Shortcuts(3pm)

NAME
Image::ExifTool::Shortcuts - ExifTool shortcut tags SYNOPSIS
This module is required by Image::ExifTool. DESCRIPTION
This module contains definitions for tag name shortcuts used by Image::ExifTool. You can customize this file to add your own shortcuts. Individual users may also add their own shortcuts to the .ExifTool_config file in their home directory (or the directory specified by the EXIFTOOL_HOME environment variable). The shortcuts are defined in a hash called %Image::ExifTool::UserDefined::Shortcuts. The keys of the hash are the shortcut names, and the elements are either tag names or references to lists of tag names. An example shortcut definition in .ExifTool_config: %Image::ExifTool::UserDefined::Shortcuts = ( MyShortcut => ['createdate','exif:exposuretime','aperture'], MyAlias => 'FocalLengthIn35mmFormat', ); In this example, MyShortcut is a shortcut for the CreateDate, EXIF:ExposureTime and Aperture tags, and MyAlias is a shortcut for FocalLengthIn35mmFormat. 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) perl v5.12.4 2011-06-10 Image::ExifTool::Shortcuts(3pm)
All times are GMT -4. The time now is 05:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy