Apple - Meaning of "./" in Mac terminal

./ 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.

Tags:

Terminal

Bash