Shell one liner to prepend to a file,
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
This still uses a temp file, but at least it is on one line:
echo "text" | cat - yourfile > /tmp/out && mv /tmp/out yourfile
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.
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