I'm currently redirecting a Python Script Output to a Log file (log) in Linux
Python Script Example (example.py):
print("output")
Shell script:
python3 example.py >> log
When I check log content (cat log
) after running example.py a few times, I get:
output
output
output
So, I'd like to add a blank line before the next "output" entry. The wanted position is:
output
output
output
What should I do in the Shell Script differently in order to achieve so (not editting example.py)?
Thanks
Update:
example.py:
print("output1")
print("output2")
When running a first time python3 example.py | sed 's/$/\n/' >> log
, I get:
output1
output2
When running it a second time:
output1
output2
output1
output2
I need to achieve:
output1
output2
output1
output2
You can add an echo
after your script finishes executing to add a trailing newline:
(python3 example.py; echo) >> log