Sponsored Content
Full Discussion: Need Multiline sed help!!
Top Forums UNIX for Dummies Questions & Answers Need Multiline sed help!! Post 302766151 by RudiC on Monday 4th of February 2013 09:46:52 AM
Old 02-04-2013
As I'm not sure if the opening square bracket that bipinajith's proposal relys on will always be present, I've come up with:
Code:
awk  '/^\-|^\+/ {intro=1}                          # test for introductory  "-" or "+", remember it
      1                                            # always print actual line
      intro && /\{/ {print "NEW CODE"; intro=0;}   # if intro remembered, and if opening brace found, add new code, and forget intro
     ' file

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete multiline string from file using sed.

Hi, I have file which has the following content... GOOD MORNING **********WARNING********** when it kicks from the kickstart, sshd daemon should start at last. (WHEN KICKING ITSELF, NOT AFTER KICKING). /etc/rc3.d/S55sshd ( run level specification for sshd is 55, now I would want to... (4 Replies)
Discussion started by: skmdu
4 Replies

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

3. Shell Programming and Scripting

sed multiline substitution if a condition holds

Hi. I have the following text file (more precisely a Matlab script): dummy1 = 5; varx = 'false'; dummy2 = 6; % ... some general commands % ... dummy3 = 7; vary = 'option1'; dummy4 = 8; Using sed I want to do the following action: IF varx = 'false' vary='NEW_VALUE_1'... (11 Replies)
Discussion started by: plsrn
11 Replies

4. UNIX for Dummies Questions & Answers

sed multiline pattern match

How can I write a script that takes a cisco config file and outputs every occurrence of two, or more, pattern matches through the whole config file? For example, out of a config file, i want to print out every line with interface, description and ip address through the whole file, and disregard... (3 Replies)
Discussion started by: knownasthatguy
3 Replies

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

6. Shell Programming and Scripting

sed - delete content inside tags multiline

I need that a certain part of the content below excluded ==Image Gallery== followed by <gallery> and the content until </gallery> test SED1 ==Image Gallery== <gallery> Image:car1.jpg| Car 1<sup>1</sup> Imagem: car2.jpg| Car2<sup>2</sup> </gallery> test SED2 ==Image... (5 Replies)
Discussion started by: dperboni
5 Replies

7. Shell Programming and Scripting

Multiline sed

Hi guys, I am fairly comfortable with using the sed command if the string to be replaced is all on a single line. I was wondering is it possible to use sed command in a multiline way ? Say for example I have the below string on 2 different lines: { "key": "brandNameA", ... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

8. Shell Programming and Scripting

[sed]: Substitute a string with a multiline value

Dear all, I try to replace a string of characters in a file (MyFile.txt) by a multiline value of the variable "Myvar": $ cat MyFile.txt DESCRIPTION '@TargetTable SCHEMA' ( @InputFlowDef ); $ The content of Myvar: $ echo "$Myvar" col1 , col2 , col3 $ (4 Replies)
Discussion started by: dae
4 Replies

9. Shell Programming and Scripting

sed multiline problem

I'm trying to replicate the sed output on p.108 of Sed&Awk,by Doughery & Robbins, 2nd edition. I'm on a Windows 10 Surface Pro, running Cygwin for 64-bit versions of Windows. Input text saved in text file called data_p108.txt: Consult Section 3.1 in the Owner and Operator Guide for a... (9 Replies)
Discussion started by: prooney
9 Replies
intro(1)						      General Commands Manual							  intro(1)

NAME
intro - Introduction to commands DESCRIPTION
Section 1 describes the commands available for all Tru64 UNIX users. Some reference pages in this section may contain suffixes to allow their files to exist with those of other reference pages having the same base name and section number. When used, suffixes are made up of one to four letters. See the man(1) reference page for more information on suffixes. Commands related to system maintenance appear in Section 8. ERRORS
On termination, each command returns two bytes of status, one supplied by the system giving the cause for termination and, in the case of normal termination, one supplied by the program. For more information, see exit(2). The first byte is 0 for normal termination; the sec- ond byte is customarily 0 for successful execution. A nonzero status indicates a problem, such as erroneous parameters, or bad or inacces- sible data. The status value is called variously exit code, exit status, or return code, and is described explicitly on reference pages only when special conventions apply. SEE ALSO
Commands: man(1) Functions: exit(2) intro(1)
All times are GMT -4. The time now is 11:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy