You really don't want to do that. watch
is designed to be, um, watched. Its output is formatted in such a way as to make redirecting it impractical. While you can actually do it using something like tee
, the output will be many blank lines and very little useful information.
So, in the specific case of watch
, you're better off writing your own little script that does the same thing:
#!/bin/bash
This is an infinite loop, the script will run until you kill it
while :; do
Run the command whose output you want to monitor
amdconfig --odgc" "amdconfig --odgt
Wait for 2 seconds. This mimics what the watch command does
and also avoids spamming your cpu.
sleep 2
done
Save that script as ~/bin/amdwatch
or whatever you like, make it executable (chmod +x ~/bin/amdwatch
) and then redirect its output to a file:
~/bin/amdwatch > amdwatch.log
That will run the script until you stop it manually and execute the amdwatch
command every two seconds, saving its output to amdwatch.log
.
For most scripts, what you are looking for is script.sh > outputFile.txt
or script.sh >> outputFile.txt
. See How do I save terminal output to a file?.
watch
and that makes things more complicated. – terdon Jan 22 '16 at 16:32