Sed Insert file between tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed Insert file between tags
# 1  
Old 04-22-2010
Sed Insert file between tags

Hi,

I have a file which has the following tags in it:

Code:
 
####STARTTAG######
 
(Then 40 lines of whitespace)
 
 
 
####ENDTAG########

What I would like to do (using sed) is to insert a another (variable length) file between these two tags.....

I have read examples and manuals unil i'm blue in the face but I can't find a solution to this fairly simple situation....

Please help!

Thanks

---------- Post updated at 11:33 AM ---------- Previous update was at 10:59 AM ----------

I found a solution:

Code:
 
sed '/STARTTAG/r "file to insert"' < "tagfile" >"tagfile.mod"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to use sed to insert character in the beginning of file path?

I need to manipulate one Database file on Solaris 11 in which contains more than 5000 lines of data file path like this: '/data1/oradata/DBNAME/system01.dbf', '/data7/oradata/DBNAME/undotbs1_01.dbf', '/data1/oradata/DBNAME/sysaux01.dbf', '/data28/oradata/DBNAME/userdata01.dbf', ... (6 Replies)
Discussion started by: duke0001
6 Replies

2. Shell Programming and Scripting

sed insert new line does not update file

Hi all, I have a file called "text.cpp" with the first line of "1" afterwards I tried in Ubuntu to type the following sed '12iasdasdasdasdsad' test.cpp > output.txt however when I tried to see the result of output.txt #cat output.txt 1 why is the line 12 is not updated to the... (6 Replies)
Discussion started by: peuceul
6 Replies

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

4. Shell Programming and Scripting

Using sed to insert text file at first line

sed '1r file.txt' <source.txt >desti.txt This example will insert 'file.txt' between line 1 and 2 of source.txt. sed '0r file.txt' <source.txt >desti.txt gives an error message. Does anyone know how 'sed' can insert 'file.txt' before the first line of source.txt? (18 Replies)
Discussion started by: psve
18 Replies

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

6. Shell Programming and Scripting

SED To insert Directory Contents to file

I am on a HP-UX machine I have a directory called "/u01/blobs" and the files look like this: ls -1 7398 7399 7400 I need to produce a comma delimited file with the following format: filename,location/filename i.e: 7398,/u01/blobs/7398 7399,/u01/blobs/7399 7400,/u01/blobs/7400 What... (3 Replies)
Discussion started by: NomDeGuerre
3 Replies

7. Shell Programming and Scripting

insert filename into file using SED (or AWK)

Hi, I would like to insert a file's filename into the first line of that file - for a batch of files. Is this possible using SED? Thanks in advance. (2 Replies)
Discussion started by: USER#5
2 Replies

8. Shell Programming and Scripting

Insert file content via sed after two searchings

Hi folks, The file webcache.xml contains a lot sections which begins and ends with the string </CACHEABILITYRULE>. The section In need to deel with is: </CACHEABILITYRULE> <CACHEABILITYRULE NAME="cache swf" CACHE="YES" COMMENT="This rule caches all .swf files. This... (2 Replies)
Discussion started by: nir_s
2 Replies

9. Shell Programming and Scripting

sed, insert data from a file to another?

Hello, I have 2 files. File1 has data I wrote, and File2 is a file created by an application. I would like to insert the data from File1 into File2, but it has to be inserted at a certain location on File2. I know I need to search for "</jsp-param> </jsp-descriptor>" But I don't know... (4 Replies)
Discussion started by: ctcuser
4 Replies

10. Shell Programming and Scripting

SED- Insert text at top of file

Does anyone know how to insert text at the top and bottom of a file using sed? (12 Replies)
Discussion started by: MBGPS
12 Replies
Login or Register to Ask a Question
curs_scroll(3)						     Library Functions Manual						    curs_scroll(3)

NAME
curs_scroll, scroll, scrl, wscrl - Scroll a Curses window SYNOPSIS
#include <curses.h> int scroll( WINDOW *win ); int scrl( int n ); int wscrl( WINDOW *win, int n ); LIBRARY
Curses Library (libcurses) STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: scrl, wscrl, scroll: XCURSES4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The scroll routine scrolls the window up one line. This involves moving the lines in the window data structure. As an optimization, if the scrolling region of the window is the entire screen, the physical screen is scrolled at the same time. The scrl and wscrl routines, for positive n, scroll the current or specified window up n lines (line i+n becomes line i); otherwise, these routines scroll the window down n lines. This operation involves moving the lines in the window character-image structure. The routines do not change the current cursor position. For the scroll, scrl, and wscrl functions to work, the scrollok option must be enabled. NOTES
The header file <curses.h> automatically includes the header file <stdio.h>. Note that scrl may be a macro. RETURN VALUES
All routines return the integer ERR upon failure and OK upon successful completion. SEE ALSO
Functions: curses(3), curs_outopts(3) Others: standards(5) curs_scroll(3)