Friday 1 February 2019

common command explanation

./ is part of the path to a directory/file.
If used as part of a parameter to a command
  • rm image.png and rm ./image.png are exactly the same and identify a file in the current directory
  • rm *./image.png is a pattern which looks for files named image.png in all subdirectories of the current directory which end with a dot
The key use for ./ usually is to call a script/executable in the current directory. When you execute a command without specifiying it's directory (e.g. cp instead of /bin/cp), the shell searches for this in all directories listed in the $PATH variable. The current directory is usually not part of that variable (for security reasons) so you can use ./command-name to tell the shell to look for the command in the current directory.

https://apple.stackexchange.com/questions/95582/meaning-of-in-mac-terminal/95584

"|" it's called pipe. It gives the output of the first command as the input to the second command.
In your case it means:
The result of sudo ps -ef is fed as the input of grep processname
sudo ps -ef:
This lists all the processes running. Type man ps in the termial for more.
grep processname
So, this list of processes is fed into grep which just searches for the program defined by programname.

Example

Typing sudo ps -ef | grep firefox in my terminal returns:

TL;DR






No comments:

Post a Comment