Linked Questions
23 questions linked to/from How can I prevent 'grep' from showing up in ps results?
7
votes
3
answers
1k
views
Why does ps aux | grep <something> return extra hit [duplicate]
Let's say I want to know the PID of kate editor that is currently running (kate is just an example, it works as described for many programs). So, I execute ps aux | grep kate.
Here is the output:
...
1
vote
8
answers
2k
views
How can I stop grep returning itself [duplicate]
# ps -ef | grep gre
root 15067 63614 0 11:03 pts/0 00:00:00 grep --color=auto gre
Another example
# ps -ef | grep sshd
root 1186 1 0 Jul26 ? 00:00:00 /usr/sbin/sshd -D
root ...
3
votes
1
answer
16k
views
grep for specific process in ps but not the grep command itself [duplicate]
If I want to check if something is running, I do ps aux | grep flamethrower, expecting just to show the processes containing flamethrower in the name. This will always find at least one process, as ...
-1
votes
1
answer
3k
views
How to do this with while loop [duplicate]
Problem is:
grep the output of ps aux for any instance of firefox, if firefox is already running, open link in new tab, if firefox is not running, start firefox and open the link.
Point to be noted ...
0
votes
1
answer
1k
views
Ignore a command as process itself while using grep on processes [duplicate]
I am writing a bash script to check if certain application is running or not. If its dead i will simply restart it.
My initial though was, check if there is one pid for that process(which in this ...
1
vote
1
answer
860
views
ps aux | grep config vs ps aux | grep "confi[g]" [duplicate]
I would like to know why ps aux | grep includes the grep command in the output but ps aux | grep "confi[g]" does not.
$ ps aux | grep config
root 50 0.0 0.0 2548368 5760 ?? Ss ...
1
vote
2
answers
124
views
number of executions of script [duplicate]
I am trying to find number of runs of a script but its always 2 even though only one running.
sh 11.sh
1
11.sh already running,exiting..
here is code.
ps -ef | grep -v grep | grep -c "$0"
if [[ `...
1
vote
2
answers
195
views
Redirect output with multiple commands [duplicate]
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 ...
0
votes
1
answer
87
views
How to create a sh script that can give as output the exact string I want using the awk command [duplicate]
I would like to have some help writing a script (which should work on FreeBSD where I have sh as default) that should grab a precise string when I do a ps ax | grep bhyve command from the terminal. ...
0
votes
0
answers
93
views
ps | grep returns two PIDs [duplicate]
I am trying to write an init.d script, I am trying to kill a named node process:
kill $(ps aux | grep 'eproxy' | awk '{print $2}')
The problem is, when running just the ps command on it's own, I am ...
0
votes
0
answers
17
views
How to returns the correct character after manipulating the output of ps ax | grep [duplicate]
I would like to have some help writing a script (which should works on freebsd where I have sh as default) that should grab a precise character when I do a "ps ax | grep" command from the ...
271
votes
5
answers
600k
views
How to suspend and bring a background process to foreground
I have a process originally running in the foreground. I suspended by Ctrl+Z, and then resume its running in the background by bg <jobid>.
I wonder how to suspend a process running in the ...
83
votes
15
answers
83k
views
How to grep a specific line _and_ the first line of a file?
Assuming a simple grep such as:
$ psa aux | grep someApp
1000 11634 51.2 0.1 32824 9112 pts/1 SN+ 13:24 7:49 someApp
This provides much information, but as the first line of the ps ...
47
votes
3
answers
32k
views
Unix command to tell how much RAM was used during program runtime? [duplicate]
Let's say I'm running a script (e.g. in Python). In order to find out how long the program took, one would run
time python script1.py
Is there a command which keeps track of how much RAM was used as ...
14
votes
2
answers
5k
views
grep - why do brackets in grep pattern remove the grep process from ps results?
Why do brackets in a grep pattern remove the grep process from ps results?
$ ps -ef | grep XXXX
[...] XXXX
[...] grep XXXX
$ ps -ef | grep [X]XXX
[...] XXXX