-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 or simply: tosi@dustpuppy:~ > echo "1 2 3" >a tosi@dustpuppy:~ > echo "4 5 6" >b tosi@dustpuppy:~ > ( cat b a ) | cat > b tosi@dustpuppy:~ > cat b 4 5 6 1 2 3 tosi@dustpuppy:~ > :-)
On Thu, Jan 25, 2001 at 09:44:17PM +0100, P.C. Uiterlinden wrote:
Martin Mielke wrote:
Dear all,
how can I append a text header to a plain-text file (source code) without deleting what's been already there?
I guess, the clue resides on 'man sed' but some examples will be much appreciated.
Here is a novel solution for you. Suppose you want to prepend (I dont think you can append to the beginning of something) Prepend contents of file1 before contents of file2
CF2=`cat file2`;cat file1 >file2;echo $CF2>>file2
Might be a limit to how much data a shell var will hold :)
Or more elegantly, suppose you have a bunch of 'c' files and you want to prepend a file called header.
# prepend header to 'c' files for FILE in *.c; do ed -s $FILE <<EOF 0r header w q EOF done
Cliff
- -- ______ /---------------------------------------\ \ | Þór Sigurðsson | Tor Sigurdsson | t | | Netmaður | Network Specialist | o | |-----------------------------------------| s | | tosi@rhi.hi.is | i | \---------------------------------------/_____/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.1e-SuSE (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6cMGd6mRH+PEpr2YRAiJgAJ9/fO1HNHp/817+VHc2X1Zrk7E47gCeNQ/8 w1Hc+/WNiw3UatomsBj0F8s= =phJs -----END PGP SIGNATURE-----