Skip to main content
added 110 characters in body
Source Link
kon
  • 123
  • 5

EDIT: Please refer to @Stéphane Chazelas answer. My updates below may be true but way to complicated.

Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

EDIT: Please refer to @Stéphane Chazelas answer. My updates below may be true but way to complicated.

Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

added 8 characters in body
Source Link
kon
  • 123
  • 5

Update:Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

Update 2:Update 2: I feel like I´ve found my mistake now.

exec 4<>"/tmp/testfile.txt"; # open FD 4 read (<) and write (>) cat <&4;<&4 >/dev/null; tee >(tee -a >&4) <<< "Output this to stdout" # read fd (>/dev/null to silent the output) for correct position and append to. Also output to stdout exec 4>&- # close FD (this closes it completly, so no need for exec 4<&-) 

Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

Update 2: I feel like I´ve found my mistake now.

exec 4<>"/tmp/testfile.txt"; # open FD 4 read (<) and write (>) cat <&4; tee >(tee -a >&4) <<< "Output this to stdout" # read fd for correct position and append to. Also output to stdout exec 4>&- # close FD (this closes it completly, so no need for exec 4<&-) 

Update: I am getting closer I guess. When trying tee <<< "Output this to stdout" >(tee -a >&4) I can actually see the output in my terminal and it writes to the file but for some reason it overrides the content and doesn´t seem to append (-a).

Update 2: I feel like I´ve found my mistake now.

exec 4<>"/tmp/testfile.txt"; # open FD 4 read (<) and write (>) cat <&4 >/dev/null; tee >(tee -a >&4) <<< "Output this to stdout" # read fd (>/dev/null to silent the output) for correct position and append to. Also output to stdout exec 4>&- # close FD (this closes it completly, so no need for exec 4<&-) 
added 2012 characters in body
Source Link
kon
  • 123
  • 5
Loading
added 252 characters in body
Source Link
kon
  • 123
  • 5
Loading
Source Link
kon
  • 123
  • 5
Loading