Answer the question
In order to leave comments, you need to log in
How to write a command to a file?
There is such a command:
ps -U user | grep program | grep -v grep | awk '{print $1}'
If executed, it will return the PID of program.
How can I write this PID to a file without outputting an extra line? Just numbers without a newline
If you just add >, it will come out like this:
But I don't want the second line to appear
Answer the question
In order to leave comments, you need to log in
ps -U user | grep program | grep -v grep | awk '{print $1}' | grep -v '^$' > pid.out
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question