Insert certain text at the beginning or end of a file with sed, regular expressions

On certain occasions we need to insert in the final from a file a text, for this we can use echo:

echo "Texto al final del archivo" >> archivo.txt

But what to do if I want to insert the text at startup?

With sed and the right parameters we can do this and more.

For example, to insert into the Home from a file a text would be:

sed -i '1i Aqui texto que ira en la primera linea' archivo.txt

While to insert into the final is

sed -i '$a Aqui el texto que ira en la ultima linea' archivo.txt

Or the echo of a lifetime:

echo "Aqui el texto que ira en la ultima linea" >> archivo.txt

Well, nothing more to add, it is a fairly short post actually.

I hope it is useful to someone, greetings.