I wanted get the resout of ps command to a file like this. (in bash)
$ps -eax |& tee list1 and I see many lines from the ps command but the file list1 is empty.
How should I do it?
To get your desired logging in parallel to terminal output, you should change
$ps -eax |& tee list1 to
$ps -eax 2>&1 | tee list1 As suggested by the discussion, it is possible that the "|&" operator is not implemented in a universal fashion, causing discrepancies from one system to the next, or that it is reacting to unspecified environmental conditions.
$ps -eax |& tee list1 again and it works today! I don't know why.
|&?list1is filled with the output of ps. So I thought maybe I was doing something wrong, and hence I asked for clarification.|&(short for2>&1 |,|&being a csh operator initially). In older versions, I'd expect a syntax error though.tee. What doestype teesay? Andtee --version?