appending

hi,

a1.txt
------

xyz zxc

xya xdf

a2.txt
------

a1 a2

b1 b2

cat a1.txt >> a2.txt -->its appending at the end

xyz zxc

xya xdf

a1 a2

b1 b2

I need to add at the beging of the file a2.txt.Is there any command
to do it?

Thanks inadvance
Mohan

not directly,

cat a1.txt a2.txt > a3.txt

Hi,

Try the following

cat a2.txt >> a1.txt

Thanks,
Shahnaz.

You can also play with the ed command :

echo "0r a1.txt\nw\nq" | ed -s a2.txt

Jean-Pierre.

Hi
Thanks,its working .Can you expain this

echo "0r a1.txt\nw\nq" | ed -s a2.txt

Thanks inadvance
Mohan

ed -s a2.txt
Edit (by line) file a2.txt, -s suppresses character counts that the editor displays.
Commands are read from stdin (output of echo command)
echo "0r a1.txt\nw\nq"
Gives commands to ed
0r a1.txt Insert file a1.txt before first line of file.
w Write file (a2.txt)
q Quit editor

Jean-Pierre.

Hi,

Thanks for your explinations

Thanks and Regards,
Mohan