Why does the following code gives only first line from ps -eaf output in ps.out?

while read line; 
do
   echo $line>ps.out; 
done < <(/bin/ps -eaf)
有帮助吗?

解决方案

You are truncating the file each time so you only get the last line. You probably want >> instead of >.

其他提示

Or redirect the entire loop output by putting ">ps.out" after the "done".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top