Sponsored Content
Top Forums Shell Programming and Scripting Print lines before after pattern meacted Post 302902038 by Optimus81 on Saturday 17th of May 2014 05:06:40 PM
Old 05-17-2014
Print lines before after pattern meacted

Hi All,

Am trying to print pervious lines of the pattern matched, I was able to print pattern matched and the required data but don't know how to get the pervious line.


Code:
 ifconfig -a | grep  10.118.67.33 | sed -e 's/^[[: :]]*//' -e 's/[[: :]]*$//' | awk '{FS=" "; print $6}'

output I get is the ipaddress ie,
Code:
 10.118.67.33

what am looking is how to get the pervious line of this ipaddress... can someone please help me on this.


Many thanks
Ops
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print certain pattern from 2 lines

i have 2 lines comming out of a script o/p.below the line. 2008-10-14 05:47:05,551 INFO - LPBatch: 2008-10-14 05:47:05,575 INFO - Number of Intervals Not Inserted: 1 / 95 -------------------------------------------------------------------------- How to print the below o/p from the... (2 Replies)
Discussion started by: ali560045
2 Replies

2. Shell Programming and Scripting

Print the above and below lines for the grep pattern.

Hi, i would like to get the above and below lines of the grep pattern . For ex : file as below: chk1- aaaa 1-Nov chk2 -aaaa ########## chk1-bbbbbb 1-Nov chk2-bbbbbb ######### my search pattern is date : 1-Nov i need the o/p as below chk1- aaaa 1-Nov (6 Replies)
Discussion started by: expert
6 Replies

3. Shell Programming and Scripting

print lines up to pattern excluding pattern

11 22 33 44 55 66 77 When pattern 55 is met, print upto it, so output is 11 22 33 44 (1 Reply)
Discussion started by: anilcliff
1 Replies

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

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

6. Shell Programming and Scripting

Print/delete the lines between two pattern.

Hello, I am having hard time figuring out how to print/delete the lines between two pattern. Here is the part of the file nastran1.bdf: RBE3 48729 32232 123456 0.30000 123 59786 59787 60114 RBE3 48732 1330 123 0.30000 123 10107... (4 Replies)
Discussion started by: dragomir
4 Replies

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

8. AIX

Grep a pattern and print following n lines

Hi all, I am struck with the below requirement. I need to grep a particular pattern in a file and then print next n lines of it for further processing. I have used the below code grep -A 3 "pattern" filename But it is throwing error as below. grep: illegal option -- A Can... (14 Replies)
Discussion started by: ssk250
14 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

10. Shell Programming and Scripting

Print lines after matching two pattern

would like to print everything after matching two patterns AAA and BBB. output : CCC ZZZ sample data : AAA BBB CCC ZZZ (4 Replies)
Discussion started by: jhonnyrip
4 Replies
BWILD(8)						     Network backup, utilities							  BWILD(8)

NAME
bwild - Bacula's 'wildcard' engine SYNOPSIS
bwild [options] -f <data-file> DESCRIPTION
This manual page documents briefly the bwild command. This is a simple program that will allow you to test wild-card expressions against a file of data. OPTIONS
A summary of options is included below. -? Show version and usage of program. -d nn Set debug level to nn. -dt Print timestamp in debug output -f <data-file> The data-file is a filename that contains lines of data to be matched (or not) against one or more patterns. When the program is run, it will prompt you for a wild-card pattern, then apply it one line at a time against the data in the file. Each line that matches will be printed preceded by its line number. You will then be prompted again for another pattern. Enter an empty line for a pattern to terminate the program. You can print only lines that do not match by using the -n option, and you can suppress printing of line numbers with the -l option. -n Print lines that do not match -l Suppress lines numbers. -i use case insensitive match. SEE ALSO
fnmatch(3) AUTHOR
This manual page was written by Bruno Friedmann <bruno@ioda-net.ch>. Kern Sibbald 30 October 2011 BWILD(8)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy