I am aware of the following options to append the output to a file:
test.py:
print "Error"
print "Warning"
test.txt:
Levels:
Debug
When I do:
python test.py > test.txt
It appends at the end of the file.
However, if I want to append at the beginning of a file, so that the output of my file looks like as follows:
Levels:
Error
Warning
Debug
Is there any straightforward way of doing this possibly without manually creating a temporary file (sed -i is OK for example).
I have tried several sed approach:
sed -i '1i\`python test.py`' test.txt
But none seems to be working.