Solved

appending text on top of another file

Posted on 2008-10-21
2
1,301 Views
Last Modified: 2013-12-13
Dear All,
I have two files
One is script file in which I am writing commands to append a text in a normal file.
I want to insert the text on top of the file.
I dont want to use sed and awk commands nor temp file.
is it possible?
0
Comment
Question by:anju_a_sagar
2 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 250 total points
ID: 22768840
try this

ed file1 <<END
r file2
.
w
q
END

This will use the ed editor to edit file1 and include file2 at the beginning then save it then quit.
0
 
LVL 14

Assisted Solution

by:sjm_ee
sjm_ee earned 250 total points
ID: 22770819
How about cat and a "here document"?

cat - /etc/motd <<!
surprise!
!
surprise!
*******************************************************************************
*                                                                             *
*                                                                             *
*  Welcome to AIX Version 5.2!                                                *
*                                                                             *
*                                                                             *
*  Please see the README file in /usr/lpp/bos for information pertinent to    *
*  this release of the AIX Operating System.                                  *
*                                                                             *
*                                                                             *
*******************************************************************************
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now