10 ms·
"." can be used any place you need to explicitly indicate a file in the current directory. Your "remove file '-f' from the current directory" is a fine example,
by delinka 15y ago
"." can be used any place you need to explicitly indicate a file in the current directory. Your "remove file '-f' from the current directory" is a fine example, but your "...can be used on non-executable files..." makes me cringe slightly - it won't magically execute a non-executable file (I do realize this is not what you mean to say...)
It works exceptionally well if you need variables for directories in a shell script. For example, if your script needs $PKG_HOME to be defined, it could be set as "/usr/bin/pkg_home/" or "./" to be prepended to other paths in the script. Setting it to "" would surely work as well as "./" but being explicit improves readability and communicates the author's intent more clearly.
So, absolute paths start with "/", relative paths may avoid "." and ".." and "/", but an explicit relative path would use "." and/or ".."