appending text on top of another file

Posted on 2008-10-21
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?
Question by:anju_a_sagar
LVL 40

Accepted Solution

omarfarid earned 250 total points
ID: 22768840
try this

ed file1 <<END
r file2

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

Assisted Solution

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

cat - /etc/motd <<!
*                                                                             *
*                                                                             *
*  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.                                  *
*                                                                             *
*                                                                             *

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reinstall 1 77
How to make the Angular JS application work in JetBrains WebStorm 11 2 80
unix example issues 18 89
Martian Packets Unix 5 50
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. Please see for the updated article. It is avail…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

815 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

13 Experts available now in Live!

Get 1:1 Help Now