Question

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)
Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top