0

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)

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

apologies for the dumb mistake. should have been >> Thx!
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.