Shell one liner to prepend to a file

Question :

Shell one liner to prepend to a file,

Answer :

This is probably.

I am looking for a simple operator like “>>”, but for prepending.

I am afraid it does not exist. I’ll have to do something like

 mv myfile tmp   cat myheader tmp > myfile  

Anything smarter?

,

This still uses a temp file, but at least it is on one line:

echo "text" | cat - yourfile > /tmp/out && mv /tmp/out yourfile  

Credit:

That’s the answer Shell one liner to prepend to a file, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  What is the difference between ++i and i++?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you