1

I'd like to redirect output from this command:

ps -eo pid,comm,cmd,start,etime | grep -i qtcreator > file.txt

When I try it, I've also output command grep -i example

2018 qtcreator qtcreator 08:11:50 01:05:00 <br> 5513 grep grep -i qtcreator 09:16:50 00:00 

How can I resolve this problem?

0

2 Answers 2

0

You can solve it by editing your command like this:

ps -eo pid,comm,cmd,start,etime | grep -i qtcreator | grep -v grep > file.txt 

In this way you are exclude the ward grep from the result of the first grep

0

I think a more cleaner way would be to use pgrep with ps:

ps -p $(pgrep <program-name>) [iahmad@localhost]$ ps -p $(pgrep sendmail) PID TTY STAT TIME COMMAND 32373 ? Ss 0:59 sendmail: accepting connections 32383 ? Ss 0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.