I have function "backup", and output for this function from the console is also redirected to a file, and it's done as follows:
backup > >(tee -a ./log.txt) 2>&1
it works, but I want to add new output data to the beginning of a file, and looks like for my case wisely use ed (not sed), and I doing it in the following way:
ed -s log.txt < <(printf '%s\n' 1i "$(backup)" . wq)
And in this case, I don't know how to implement the output to the console and the file at once (as it happens in my first case). Can somebody give me a hint of implementation?
If I understand your code correctly - you are trying to pre-pend the output of the backup command to the start of the log.txt file. Moreover, you are trying to see the backup output on the console.
Try this:
Edit:
Here's a version of the code that follows Charles Duffy's suggestion: