Sponsored Content
Top Forums Shell Programming and Scripting awk print pattern match line and following lines Post 302791891 by ctsgnb on Tuesday 9th of April 2013 12:12:22 PM
Old 04-09-2013
To print the line containing pattern and the next following line :

Code:
awk '/pattern/{c=3}{c>0?c--:c=0}c' myfile

or
Code:
awk '{y=x;x=($0~/pattern/)?1:0}x||y' myfile

or
Code:
awk '/pattern/{c=3}--c>0' myfile


Last edited by ctsgnb; 04-09-2013 at 01:25 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed print all lines after pattern match

HiCan someone show me how to print all lines from a file after a line matching a pattern using sed?Thanks (13 Replies)
Discussion started by: steadyonabix
13 Replies

2. Shell Programming and Scripting

awk to print lines based on string match on another line and condition

Hi folks, I have a text file that I need to parse, and I cant figure it out. The source is a report breaking down softwares from various companies with some basic info about them (see source snippet below). Ultimately what I want is an excel sheet with only Adobe and Microsoft software name and... (5 Replies)
Discussion started by: rowie718
5 Replies

3. Shell Programming and Scripting

print chunk of lines only if there is a pattern match in between them

Hi All, Please find the sample file below: NAME ID NUMBER -------------------------------------------------------------------------------------------------- --------- abcdefgheija;lksdf ... (13 Replies)
Discussion started by: niel.verty
13 Replies

4. Shell Programming and Scripting

print lines with exact pattern match

I have in a file domain.com. 1909 IN A 1.22.33.44 domain.com. 1909 IN A 22.33.44.55 ns1.domain.com. 1699 IN A 33.44.55.66 ns2.domain.com. 1806 IN A 77.77.66.66 I need to "grep" or "awk" out the lines starting with domain.com. as follows. domain.com. 1909 IN A 1.22.33.44 domain.com.... (3 Replies)
Discussion started by: anilcliff
3 Replies

5. Shell Programming and Scripting

Print lines before and after pattern match

I am using Solaris, I want to print 3 lines before pattern match pattern 5 lines after pattern match Pattern is abcd to be searched in a.txt. Looking for the solution in sed/awk/perl. Thanks .. Input File a.txt: ================= 1 2 3 abcd 4 5 6 7 8 (7 Replies)
Discussion started by: manuswami
7 Replies

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

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

Match pattern and print the line number of occurence using awk

Hi, I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example: inputfile abd abp 123 abc abc 325 ndc ndc 451 mjk lkj... (3 Replies)
Discussion started by: redse171
3 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. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies
DCFILE(1)					      DICOM PS3 - Describe DICOM file content						 DCFILE(1)

NAME
dcfile - ACR/NEMA DICOM PS3 ... DICOM PS3 - Describe DICOM file content SYNOPSIS
dcfile [ -b|brief ] [ -filename ] DESCRIPTION
dcfile reads the named dicom or acr-nema input file and describes the encoding method of the file, ie. what transfer syntax is in use, and whether or not a Part 10 style meta-information header is present. OPTIONS
The description goes to standard error. The basic input switches are described in dcintro(1). Options specific to this program are: -b|brief Display a single line brief summary. -filename Show the name of the file supplied in the arguments; a hyphen will be reported if no filename was supplied. ENVIRONMENT
EXAMPLES
% dcfile dicomdir. Meta: UID 1.2.840.10008.1.2.1 Meta: Description "Explicit VR Little Endian" Meta: ByteOrder Little Meta: VR Explicit Meta: Encapsulated No Data: UID 1.2.840.10008.1.2.1 Data: Description "Explicit VR Little Endian" Data: ByteOrder Little Data: VR Explicit Data: Encapsulated No % dcfile expmeta.dc3 Meta: UID 1.2.840.10008.1.2.1 Meta: Description "Explicit VR Little Endian" Meta: ByteOrder Little Meta: VR Explicit Meta: Encapsulated No Data: UID 1.2.840.10008.1.2 Data: Description "Implicit VR Little Endian" Data: ByteOrder Little Data: VR Implicit Data: Encapsulated No % dcfile NM.1 Data: UID 1.2.840.10008.1.2 Data: Description "Implicit VR Little Endian" Data: ByteOrder Little Data: VR Implicit Data: Encapsulated No % dcfile test.spi Data: ByteOrder Big Data: VR Implicit Data: Encapsulated No % dcfile -b evrlewm.dcm DICOM file, with metaheader, Explicit VR Little Endian % dcfile -b evrlenom.dcm DICOM file, no metaheader, Explicit VR Little Endian FILES
SEE ALSO
file(1), dcdump(1), dcintro(1) AUTHOR
Copyright (C) 1993-2010. David A. Clunie DBA PixelMed Publishing. All rights reserved. BUGS
DICOM PS3 6 March 2007 DCFILE(1)
All times are GMT -4. The time now is 09:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy