Sponsored Content
Top Forums Shell Programming and Scripting Sed; insert text two lines above match Post 302960455 by indo1144 on Monday 16th of November 2015 04:39:22 AM
Old 11-16-2015
Hi All!
Thanks for the replies! I'm afraid I wasn't clear enough in my initial example. I realized that when I received my first reply, but I wasn't able to reply anymore.

The separator is NOT the last line in the file, I want to automatically insert a line into an existing changelog, that is part of a script, which starts below the separator...
I would like to use the separator, because sometimes the comments in the changelog span multiple lines, so I can't look for the last v000x and append a new line below it.

Like so:

Code:
# v0004 - Some text
# v0005 - More text
# v0006 - New text
#
######SEPARATOR#####
Script start here...

---------- Post updated at 10:39 AM ---------- Previous update was at 10:33 AM ----------

Never mind. RudiC's piece of code, even though it's completely incomprehensible, does the job!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

2. Shell Programming and Scripting

sed problem - delete all lines until a match on 2 lines

First of all, I know this can be more eassily done with perl or other scripting languages but, that's not the issue. I need this in sed. (or wander if it's possible ) I got a file (trace file to recreate the control file from oracle for the dba boys) which contains some lines another line... (11 Replies)
Discussion started by: plelie2
11 Replies

3. Shell Programming and Scripting

Insert text file only after the first match with SED

Hello, I'm new in Shell scripting but i should write a script, which inserts the license header out of a txt-File into the files in our Projekt. For the Java classes it runs without Problems but for XML files not. At xml-files i have to put the license Header after the xml-Header (?xml... (1 Reply)
Discussion started by: PhoenixONE
1 Replies

4. Shell Programming and Scripting

Insert few lines above a match using sed, and within a perl file.

Greetings all, I am trying to match a string, and after that insert a few lines above that match. The string is "Version 1.0.0". I need to insert a few lines ONLY above the first match (there are many Version numbers in the file). The rest of the matches must be ignored. The lines I need to... (2 Replies)
Discussion started by: nagaraj s
2 Replies

5. Shell Programming and Scripting

sed insert text 2 lines above pattern

Hi I am trying to insert a block of text 2 lines above a pattern match using sed eg #Start of file entry { } #End of file entry new bit of text has to be put in just above the } eg #Start of file entry { New bit of text } #End of file entry (7 Replies)
Discussion started by: eeisken
7 Replies

6. Shell Programming and Scripting

How to insert line with between two consecutive lines that match special pattern?

I have following pattern in a file: 00:01:38 UTC abcd 00:01:48 UTC 00:01:58 UTC efgh 00:02:08 UTC 00:02:18 UTC and I need to change something like the following 00:01:38 UTC abcd 00:01:48 UTC XXXX 00:01:58 UTC efgh 00:02:08 UTC XXXX (6 Replies)
Discussion started by: jjnight
6 Replies

7. Shell Programming and Scripting

Using sed to insert text between lines

Hello, I am trying to insert a section of text between lines in another text file. The new lines to be inserted are: abcd.efgh.zzzz=blah abcd.efgh.xxxx=blah Where N = 0 to 2 Original File: abcd.efgh.wwxx=aaaaa abcd.efgh.yyzz=bbbbb abcd.efgh.wwxx=aaaaa abcd.efgh.yyzz=bbbbb... (3 Replies)
Discussion started by: tsu3000
3 Replies

8. Shell Programming and Scripting

Search a certain char and insert new text if a match found

Have a file which has the create statement like below create table emp ( empno integer, empname char(50)) primary index(empno); i need to find a string starting with create and ends with semi-colon ;. if so insert the below statement before create statement rename table emp to emp_rename;... (2 Replies)
Discussion started by: Mohan0509
2 Replies

9. Shell Programming and Scripting

Insert text after match in XML file

Having a little trouble getting this to work just right. I have xml files that i want to split some data. I have 2 <name> tags within the file I would like to take only the first tag and split the data. tag example. From this. TAB<Name>smith, john</Name> to TAB<Name>smith,... (8 Replies)
Discussion started by: whegra
8 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
doctools::changelog(3tcl)					Documentation tools					 doctools::changelog(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
doctools::changelog - Processing text in Emacs ChangeLog format SYNOPSIS
package require Tcl 8.2 package require textutil package require doctools::changelog ?1? ::doctools::changelog::scan text ::doctools::changelog::toDoctools title module version entries ::doctools::changelog::merge entries... _________________________________________________________________ DESCRIPTION
This package provides Tcl commands for the processing and reformatting of text in the "ChangeLog" format generated by emacs. API
::doctools::changelog::scan text The command takes the text and parses it under the assumption that it contains a ChangeLog as generated by emacs. It returns a data structure describing the contents of this ChangeLog. This data structure is a list where each element describes one entry in the ChangeLog. Each element/entry is then a list of three elements describing the date of the entry, its author, and the comments made, in this order. The last item in each element/entry, the comments, is a list of sections. Each section is described by a list containing two elements, a list of file names, and a string containing the true comment associated with the files of the section. { { date author { { {file ...} commenttext } ... } } {...} } ::doctools::changelog::toDoctools title module version entries This command converts the pre-parsed ChangeLog entries as generated by the command ::doctools::changelog::scan into a document in doctools format and returns it as the result of the command. The other three arguments supply the information for the header of that document which is not available from the changelog itself. ::doctools::changelog::merge entries... Each argument of the command is assumed to be a pre-parsed Changelog as generated by the command ::doctools::changelog::scan. This command merges all of them into a single structure, and collapses multiple entries for the same date and author into a single entry. The new structure is returned as the result of the command. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category doctools of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
changelog, doctools, emacs CATEGORY
Documentation tools COPYRIGHT
Copyright (c) 2003-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net> doctools 1 doctools::changelog(3tcl)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy