Insert a file at specific line


 
Thread Tools Search this Thread
Operating Systems Solaris Insert a file at specific line
# 1  
Old 08-13-2013
Insert a file at specific line

Hi,

Anyone can help me in Solaris command on how to insert a file at specific line.

I want file1.sql content to be inserted on file2.sh after "recover database using backup controlfile until cancel".

# file1.sql
Code:
/archivelogs/927_822338133.arc
/archivelogs/671_822338107.arc
/archivelogs/911_822340363.arc

# file2.sh
Code:
#!/usr/bin/sh
sqlplus -s / as sysdba <<!
recover database using backup controlfile until cancel
cancel
exit
!

Thank in advance.

Regards,
FSPalero

Last edited by Franklin52; 08-13-2013 at 03:20 AM.. Reason: Please use code tags
# 2  
Old 08-13-2013
Here is one way:
Code:
ed file2.sql <<%
/recover database using backup controlfile until cancel
.r file1.sql
w 
%

# 3  
Old 08-13-2013
Code:
sed '/recover/ r file1' file2
#!/usr/bin/sh
sqlplus -s / as sysdba <<!
recover database using backup controlfile until cancel
/archivelogs/927_822338133.arc
/archivelogs/671_822338107.arc
/archivelogs/911_822340363.arc
cancel
exit
!

# 4  
Old 08-16-2013
Hi,

Many thanks for the help.

Regards,
FSPalero
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 insert new line after a specific character in scripts?

Hi, I'm trying to add a new line after finding a specific String. That is my string: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html and I want to change that file to: volumes: - ${DIR_WORK}/loadbalancer/html:/var/www/html extra_hosts: -... (4 Replies)
Discussion started by: siamak
4 Replies

2. Shell Programming and Scripting

Insert character at specific location in a each line of the file

Hi All, I am trying to write a shell script where it should insert character 'I' in 180th position of each line(except first and last line) of the file. Below is the script for file in /home/test/bharat/*.RET do # Process file echo "File Name=" $file #l_fileName="${file##*/}" ... (19 Replies)
Discussion started by: bharath561989
19 Replies

3. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

4. Shell Programming and Scripting

I want to insert "#" at specific line in file

input i am good output #i am good (6 Replies)
Discussion started by: vipin auja
6 Replies

5. Shell Programming and Scripting

Insert text line to specific location CSV

In Perl. ***edited question below*** Hey all, I am teaching myself some simple CSV file manipulation and have become a little stuck. Say I have the following layout in the CSV file: age,name,locationIs it possible to INSERT data into the CSV into the correct age order. For example, if I had... (1 Reply)
Discussion started by: whyte_rhyno
1 Replies

6. Shell Programming and Scripting

Korn Shell script to insert at specific line

Hi, I am trying to put together a Korn Shell script to insert at a specific line. The system we use is SunOS 5.10 I can get the line number by using:- num=`sed -n '/export ENV/=' ./tmp.file` Not getting much headway using the above variable's value to insert - export SYBASE=/opt/sybase15... (5 Replies)
Discussion started by: aj8200
5 Replies

7. Shell Programming and Scripting

Insert specific line when found similar value

Hi All, I have file like this: file1: 3778 10474 24 3778 10475 24 3778 10476 25 3778 10495 26 3794 10001 33 3794 10002 33 3794 10004 33 3794 10007 34 3794 10008 34 3794 10011 34 3794 10012 34 3794 10013 34 3794 10017 34 3810 10282 27 (6 Replies)
Discussion started by: attila
6 Replies

8. Shell Programming and Scripting

search a line and insert string into specific at position

Hi, guys. I have one question: How can I search for a line with certain string in it and then insert a string into this line? For example: There is a file called shadow, the contents of it are below: ************************** ... yuanz:VIRADxMsadfDF/Q:0:0:50:7:::... (9 Replies)
Discussion started by: daikeyang
9 Replies

9. Shell Programming and Scripting

insert a line after specific line

Hii, I have a file like this-- Here i want to replace the line o: Torry Harris with o: Torry arris Business Solutions and in file there are places where this line is not there after the Mobile number,so i want to insert the line as --o: Torry arris Business Solutions. i can replace it... (8 Replies)
Discussion started by: namishtiwari
8 Replies

10. Shell Programming and Scripting

Insert lines at specific location in file

Hi There I have this file that I would like to add entries to, however, there is a "}" as the last line that I need to keep. Basically i would like to know how I can write a script that will add new lines at the second to last line position (ie always add new line above the close bracket) ... (17 Replies)
Discussion started by: hcclnoodles
17 Replies
Login or Register to Ask a Question