Sponsored Content
Top Forums Shell Programming and Scripting Sed/awk/perl command to replace pattern in multiple lines Post 302747213 by spacebar on Thursday 20th of December 2012 11:59:32 PM
Old 12-21-2012
Try it using this format:
Code:
sed 'beginning_line#,ending_line# s/pattern/new pattern/' file_name

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed command to replace multiple lines

the file contains the follwoing lines /* * Copyright (C) 1995-1996 by XXX Corporation. This program * contains proprietary and confidential information. All rights reserved * except as may be permitted by prior written consent. * * $Id: xxx_err.h,v 1.10 2001/07/26 18:48:34 zzzz $ ... (1 Reply)
Discussion started by: radha.kalivar
1 Replies

2. Shell Programming and Scripting

Perl: Printing Multiple Lines after pattern match

Hello People, Need some assistance/guidance. OUTLINE: Two files (File1 and File2) File1 has some ids such as 009463_3922_1827 897654_8764_5432 File2 has things along the lines of: Query= 009463_3922_1827 length=252 (252 letters) More stufff here ... (5 Replies)
Discussion started by: Deep9000
5 Replies

3. Shell Programming and Scripting

sed/awk to insert multiple lines before pattern

I'm attempting to insert multiple lines before a line matching a given search pattern. These lines are generated in a separate function and can either be piped in as stdout or read from a temporary file. I've been able to insert the lines from a file after the pattern using: sed -i '/pattern/... (2 Replies)
Discussion started by: zksailor534
2 Replies

4. Shell Programming and Scripting

awk/sed/perl command to delete specific pattern and content above it...

Hi, Below is my input file: Data: 1 Length: 20 Got result. Data: 2 Length: 30 No result. Data: 3 Length: 20 (7 Replies)
Discussion started by: edge_diners
7 Replies

5. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

6. Shell Programming and Scripting

Replace multiple lines through sed

Hi All, I have a input file as sample below <this is not starting of file> record line1 line2 line3 end line4 line5 record line6 line7 line8 my requirement is this, i want to select a pattern between first record and end, whatever is written between first record and end. and... (0 Replies)
Discussion started by: adgangwar
0 Replies

7. Shell Programming and Scripting

Sed replace using same pattern repeating multiple times in a line

Sed replace using same pattern repeating multiple times in a line I have text like below in a file: I am trying to replace the above line to following How can I acheive this? I am able to do it if the occurrence is for 1 time: But If I try like below I am getting like this: I have to... (4 Replies)
Discussion started by: sol_nov
4 Replies

8. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

9. Shell Programming and Scripting

sed command to replace two character pattern with another pattern

Not able to paste my content. Please see the attachment :-( (2 Replies)
Discussion started by: vivek d r
2 Replies

10. Shell Programming and Scripting

Sed/awk/perl substitution with multiple lines

OSX I have been grinding my teeth on a portion of code. I am building a bash script that edits a html email template. In the template, I have place holders for SED (or whatever program is appropriate) to use as anchors for find and replace, with user defined corresponding html code. The HTML code... (3 Replies)
Discussion started by: sudo
3 Replies
Mojolicious::Routes::Pattern(3pm)			User Contributed Perl Documentation			 Mojolicious::Routes::Pattern(3pm)

NAME
Mojolicious::Routes::Pattern - Routes pattern engine SYNOPSIS
use Mojolicious::Routes::Pattern; # Create pattern my $pattern = Mojolicious::Routes::Pattern->new('/test/:name'); # Match routes my $result = $pattern->match('/test/sebastian'); say $result->{name}; DESCRIPTION
Mojolicious::Routes::Pattern is the core of Mojolicious::Routes. ATTRIBUTES
Mojolicious::Routes::Pattern implements the following attributes. "defaults" my $defaults = $pattern->defaults; $pattern = $pattern->defaults({foo => 'bar'}); Default parameters. "format" my $regex = $pattern->format; $pattern = $pattern->format($regex); Compiled regex for format matching. "pattern" my $pattern = $pattern->pattern; $pattern = $pattern->pattern('/(foo)/(bar)'); Raw unparsed pattern. "quote_end" my $quote = $pattern->quote_end; $pattern = $pattern->quote_end(']'); Character indicating the end of a quoted placeholder, defaults to ")". "quote_start" my $quote = $pattern->quote_start; $pattern = $pattern->quote_start('['); Character indicating the start of a quoted placeholder, defaults to "(". "regex" my $regex = $pattern->regex; $pattern = $pattern->regex($regex); Pattern in compiled regex form. "relaxed_start" my $relaxed = $pattern->relaxed_start; $pattern = $pattern->relaxed_start('*'); Character indicating a relaxed placeholder, defaults to "#". "reqs" my $reqs = $pattern->reqs; $pattern = $pattern->reqs({foo => qr/w+/}); Regex constraints. "symbol_start" my $symbol = $pattern->symbol_start; $pattern = $pattern->symbol_start(':'); Character indicating a placeholder, defaults to ":". "symbols" my $symbols = $pattern->symbols; $pattern = $pattern->symbols(['foo', 'bar']); Placeholder names. "tree" my $tree = $pattern->tree; $pattern = $pattern->tree([ ... ]); Pattern in parsed form. "wildcard_start" my $wildcard = $pattern->wildcard_start; $pattern = $pattern->wildcard_start('*'); Character indicating the start of a wildcard placeholder, defaults to "*". METHODS
Mojolicious::Routes::Pattern inherits all methods from Mojo::Base and implements the following ones. "new" my $pattern = Mojolicious::Routes::Pattern->new('/:action'); my $pattern = Mojolicious::Routes::Pattern->new('/:action', action => qr/w+/); my $pattern = Mojolicious::Routes::Pattern->new(format => 0); Construct a new pattern object. "match" my $result = $pattern->match('/foo/bar'); my $result = $pattern->match('/foo/bar', 1); Match pattern against entire path, format detection is disabled by default. "parse" $pattern = $pattern->parse('/:action'); $pattern = $pattern->parse('/:action', action => qr/w+/); $pattern = $pattern->parse(format => 0); Parse a raw pattern. "render" my $path = $pattern->render({action => 'foo'}); my $path = $pattern->render({action => 'foo'}, 1); Render pattern into a path with parameters, format rendering is disabled by default. "shape_match" my $result = $pattern->shape_match($path); my $result = $pattern->shape_match($path, 1); Match pattern against path and remove matching parts, format detection is disabled by default. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojolicious::Routes::Pattern(3pm)
All times are GMT -4. The time now is 11:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy