The shell standard output redirects to the last line of the file, is there a way to write it to the first line of the file?
Since the content of stdout is unpredictable, I suspect that this may require changing the default behavior of stdout, but I am not sure if it is feasible.
Example, redirecting a timestamp to file
echo `date` >> test.txt
Default save to last line of file
Mon Aug 31 00:40:27 UTC 2020
Mon Aug 31 00:40:28 UTC 2020
Mon Aug 31 00:40:29 UTC 2020
Mon Aug 31 00:40:30 UTC 2020
Desired effect, save the output to the first line of the file
Mon Aug 31 00:40:30 UTC 2020
Mon Aug 31 00:40:29 UTC 2020
Mon Aug 31 00:40:28 UTC 2020
Mon Aug 31 00:40:27 UTC 2020
Thanks in advance!
tac test.txt
echo $(date)
?