Reputation: 1
I have the following command that works fine however writing this command in a "more proper" manner, the tee -a
fails to append each line to the .log file. (Instead it overwrites the file with only the last tee output) I'm just curious as to why the tee -a
isn't working as expected in the 2nd example below.
OS: RHEL 8.9 (Shell: zsh)
Properly displays output and appends all three commands to file:
date >> ./net.log | tee && ifconfig | awk 'NR == 4' >> ./net.log | tee && ifconfig | awk 'NR == 6' >> ./net.log | tee
Properly displays output but does not append to file (overwrites file with last command only):
date | tee -a ./net.log && ifconfig | awk 'NR == 4' | tee -a ./net.log && ifconfig | awk 'NR == 6' | tee -a ./net.log
Upvotes: -2
Views: 70
Reputation: 39
you are almost there. try the following
(date && ifconfig | awk 'NR == 4' && ifconfig | awk 'NR == 6') | tee -a ./net.log
Upvotes: 0