-a Select all processes except both session leaders (see getsid(2)) and
processes not associated with a terminal.
-f Do full-format listing. This option can be combined
with many other UNIX-style options to add additional
columns. It also causes the command arguments to be
printed. When used with -L, the NLWP (number of
threads) and LWP (thread ID) columns will be added. See
the c option, the format keyword args, and the format
keyword comm.
-e Select all processes. Identical to -A.
As you can see the output shows the lines matching my current working directory, which is /home/saji.
Background info:
If a command is in $(...) or ..., then the command is run and the output (what is printed to the screen) is caught and substituted to where the original $() or `` string was. So the actual command run is grep pwd.
For more information refer this link.(Thanks to @minerz029 for this information).
Do check out the following link for a detailed technical answer from the man pages itself:
I guess you have a file named selenium.jar but no file called selenium in your current folder.
If you run
ps aux | grep [s]elenium.jar
the shell will try to replace [s]elenium.jar with matching files names from the current folder. If there is a file called selenium.jar that will match and [s]elenium.jar will be replaced by selenium.jar.
The shell will then execute the command with the replaced value, i.e.
ps aux | grep selenium.jar
To avoid this quote the regex to protect it from the shell:
-e and -f are options to the ps command, and pipes take the output of one command and pass it as the input to another. Here is a full breakdown of this command:
ps - list processes
-e - show all processes, not just those belonging to the user
-f - show processes in full format (more detailed than default)
command 1 | command 2 - pass output of command 1 as input to command 2
grep find lines containing a pattern
processname - the pattern for grep to search for in the output of ps -ef
So altogether
ps -ef | grep processname
means: look for lines containing processname in a detailed overview/snapshot of all current processes, and display those lines
Best Answer
From the man page for ps:
grep is used to
print lines matching a pattern
.What it does
The command
prints out all the lines matching the output of the command
pwd
(which will be the path your current working directory), from the output ofps -aef
.e.g:
As you can see the output shows the lines matching my current working directory, which is
/home/saji
.Background info:
If a command is in $(...) or
...
, then the command is run and the output (what is printed to the screen) is caught and substituted to where the original $() or `` string was. So the actual command run is grep pwd.For more information refer this link.(Thanks to @minerz029 for this information).
Do check out the following link for a detailed technical answer from the man pages itself:
http://explainshell.com/explain?cmd=ps+-aef+|+grep+%60pwd%60