Sponsored Content
Top Forums Shell Programming and Scripting Sed; insert text two lines above match Post 302960216 by indo1144 on Thursday 12th of November 2015 10:09:22 AM
Old 11-12-2015
Sed; insert text two lines above match

Hi!

Considering below text, how would I use sed to insert text right below the v0005-line, using the SEPARATOR-line as a pattern to search for, so two lines above the separator? I can do it right above the separator, but not 2 lines...

Code:
# v0004 - Some text
# v0005 - More text
#
######SEPARATOR#####

My goal is to insert another line, like so:

Code:
# v0004 - Some text
# v0005 - More text
# v0006 - New text
#
######SEPARATOR#####

 

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
CLUBAK(1)						     ClusterShell User Manual							 CLUBAK(1)

NAME
clubak - format output from clush/pdsh-like output and more SYNOPSIS
clubak [ OPTIONS ] DESCRIPTION
clubak formats text from standard input containing lines of the form "node:output". It is fully backward compatible with dshbak(1) but provides additonal features. For instance, clubak always displays its results sorted by node/nodeset. You do not need to use clubak when using clush(1) as all output formatting features are already included in. It is provided for other usages, like post-processing results of the form "node:output". Like clush(1), clubak uses the ClusterShell.MsgTree module of the ClusterShell library (see pydoc ClusterShell.MsgTree). INVOCATION
clubak should be started with connected standard input. OPTIONS
--version show clubak version number and exit -b, -c gather nodes with same output (-c is provided for dshbak(1) compatibility) -d, --debug output more messages for debugging purpose -L disable header block and order output by nodes -r, --regroup fold nodeset using node groups -s GROUPSOURCE, --groupsource=GROUPSOURCE optional groups.conf(5) group source to use -G, --groupbase do not display group source prefix (always @groupname) -S SEPARATOR, --separator=SEPARATOR node / line content separator string (default: :) -F, --fast faster but memory hungry mode (preload all messages per node) -T, --tree message tree trace mode; switch to enable ClusterShell.MsgTree trace mode, all keys/nodes being kept for each message element of the tree, thus allowing special output gathering --color=WHENCOLOR whether to use ANSI colors to surround node or nodeset prefix/header with escape sequences to display them in color on the terminal. WHENCOLOR is never, always or auto (which use color if standard output refers to a terminal). Color is set to [34m (blue foreground text) and cannot be modified. --diff show diff between gathered outputs EXIT STATUS
An exit status of zero indicates success of the clubak command. EXAMPLES
1. clubak can be used to gather some recorded clush(1) results: Record clush(1) results in a file: # clush -w node[1-7] uname -r >/tmp/clush_output # clush -w node[32-159] uname -r >>/tmp/clush_output Display file gathered results (in line-mode): # clubak -bL </tmp/clush_output 2. Another example, iterate over node* text files in current directory and gather characters count for all of them: # find -name "node*" -exec wc -c {} ; | awk '{ gsub("./","",$2); print $2": "$1 }' | clubak -bL node[1,3]: 7 node2: 9 SEE ALSO
clush(1), nodeset(1), groups.conf(5). BUG REPORTS
Use the following URL to submit a bug report or feedback: https://github.com/cea-hpc/clustershell/issues AUTHOR
Stephane Thiell, CEA DAM <stephane.thiell@cea.fr> COPYRIGHT
CeCILL-C V1 1.6 2012-03-28 CLUBAK(1)
All times are GMT -4. The time now is 02:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy