Sponsored Content
Full Discussion: sed multiline pattern match
Top Forums UNIX for Dummies Questions & Answers sed multiline pattern match Post 302638861 by kristinu on Thursday 10th of May 2012 08:43:23 PM
Old 05-10-2012
Code:
cat test.txt

interface Loopback1111
description aaaa
ip vrf forwarding vaaaa
ip address 1.1.1.1
!
interface Loopback2222
description bbbb
ip vrf forwarding vbbbb
ip address 2.2.2.2
!


sed -n '/interface\|description\|ip/p'  test.txt

interface Loopback1111
description aaaa
ip vrf forwarding vaaaa
ip address 1.1.1.1
interface Loopback2222
description bbbb
ip vrf forwarding vbbbb
ip address 2.2.2.2

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk match a multiline pattern

Hello! i wanna match in a config file, one text with more than one lines, something like this: CACHE_SIZE{ 10000 M } I have problems with the ends of line, i think that i can match the end of the line with \n, but i can't get it Someone can help me with the regular expression? ... (18 Replies)
Discussion started by: claw82
18 Replies

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

3. Shell Programming and Scripting

Multiline pattern search using sed or awk

Hi friends, Could you please help me to resolve the below issue. Input file :- <Node> <username>abc</username> <password>ABC</password> <Node> <Node> <username>xyz</username> <password>XYZ</password> <Node> <Node> <username>mnp</username> ... (3 Replies)
Discussion started by: haiksuresh
3 Replies

4. Shell Programming and Scripting

sed pattern match problem

Hi all, hoping this is a simple one, tried looking but just can't see the solution As an example I've got a list of words that all start Ben..... Bendicks Benefiber Ben Benylin I need to only change the line Ben with Ben 10, ignoring the other lines. I tried the following ... (1 Reply)
Discussion started by: mrpugster
1 Replies

5. Shell Programming and Scripting

Match a pattern starting with sub-pattern using sed

Hi all, I've been experiencing a difficulty trying to match a number and write it to a new file. My input file is: input.txt It contains the lines: 103P 123587.256971 3.21472112 3.1517423 1.05897234566427 58.2146258 12.35478 25.3612489 What would be the sed command to... (17 Replies)
Discussion started by: Biederman
17 Replies

6. Shell Programming and Scripting

Sed Pattern Match

Hi, I would like to use SED to do the following string replacement: asd1abc to www1cda asd2abc to www2cda ... asd9abc to www9cda I can use 'asd.abc' to find the orignal string, however I don't know how to generate the target string. Any suggestion? Thanks, ... (2 Replies)
Discussion started by: mail4mz
2 Replies

7. Shell Programming and Scripting

Using sed to pattern match within a particular multiline block and take action

Hi all, This is my first post, so please go easy if I broke some rules. Not accustomed to posting in forums... :) I'm looking for help on pattern matching within a multiline block and looking to highlight blocks/block-ids that do NOT contain a particular pattern. For example an input file... (5 Replies)
Discussion started by: tirodad
5 Replies

8. Shell Programming and Scripting

sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times. But it isnt working on the new linux box sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf its driving me nuts !! Is there something Im missing ? (7 Replies)
Discussion started by: popeye
7 Replies

9. Shell Programming and Scripting

Pattern match with awk/sed - help

I need to grep for the pattern text inside the square brackets which are in red and not in green..my current code greps patterns both of them, which i don't want Input fileref|XP_002371341.1| oxoacyl-ACP reductase, putative gb|EPT24759.1| 3-ketoacyl-(acyl-carrier-protein) reductase ... (2 Replies)
Discussion started by: selvankj
2 Replies

10. Shell Programming and Scripting

Get range out using sed or awk, only if given pattern match

Input: START OS:: UNIX Release: xxx Version: xxx END START OS:: LINUX Release: xxx Version: xxx END START OS:: Windows Release: xxx Version: xxx ENDHere i am trying to get all the information between START and END, only if i could match OS Type. I can get all the data between the... (3 Replies)
Discussion started by: Dharmaraja
3 Replies
DEBCONF-COPYDB(1)						      Debconf							 DEBCONF-COPYDB(1)

NAME
debconf-copydb - copy a debconf database SYNOPSIS
debconf-copydb sourcedb destdb [--pattern=pattern] [--owner-pattern=pattern] [--config=Foo:bar] DESCRIPTION
debconf-copydb copies items from an existing debconf database into another, possibly new database. The two databases may have different formats; if so a conversion will automatically be done. OPTIONS
sourcedb The name of the source database. Typically it will be defined in your debconf.conf (or .debconfrc) file. destdb The name of the destination database. It may be defined in debconf.conf or .debconfrc, or you might define it on the command line (see below). -p pattern, --pattern pattern If this is specified, only items in sourcedb whose names match the pattern will be copied. --owner-pattern pattern If this is specified, only items in sourcedb whose owners match the pattern will be copied. -c foo:bar, --config Foo:bar Set option Foo to bar. This is similar to writing: Foo: bar In debconf.conf, except you probably want to leave off the space on the command line (or quote it: "Foo: bar"). Generally must be used multiple times, to build up a full configuration stanza. While blank lines are used to separate stanzas in debconf.conf, this program will assume that "Name:dbname" denotes the beginning of a new stanza. EXAMPLES
debconf-copydb configdb backup Copy all of configdb to backup, assuming you already have the backup database defined in debconf.conf. debconf-copydb configdb newdb --pattern='^slrn/' --config=Name:newdb --config=Driver:File --config=Filename:newdb.dat Copy slrn's data out of configdb, and into newdb. newdb is not defined in the rc file, so the --config switches set up the database on the fly. debconf-copydb configdb stdout -c Name:stdout -c Driver:Pipe -c InFd:none --pattern='^foo/' Spit out all the items in the debconf database related to package foo. debconf-copydb configdb pipe --config=Name:pipe --config=Driver:Pipe --config=InFd:none | ssh remotehost debconf-copydb pipe configdb --config=Name:pipe --config=Driver:Pipe This uses the special purpose pipe driver to copy a database to a remote system. SEE ALSO
debconf.conf(5) AUTHOR
Joey Hess <joeyh@debian.org> 2012-09-10 DEBCONF-COPYDB(1)
All times are GMT -4. The time now is 01:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy