When I run mdls -name kMDItemFSName -name kMDItemDateAdded -raw * in zsh in a folder containing the directory - Java Code, I get the following error:
mdls: unrecognized option `- Java Code'
How can I fix this? I tried using "*", but it didn't glob at all.
The problem is because of the
-option in one of the directories. Usually the command line flags are given following a-. A folder name as-Java Codeis being treated as one such flags tomdlscommand which it doesn't like. Usually we provide an end of command line flags separator by providing a--upon which the shell realizes that no more command line flags are expected.This way since we signaled that the command line flags are done, a folder name containing a leading
-should be parsed properly.The problem is a frequently occurring one and can be simply reproduced by a simple
mvcommand and creating a file containing a-and when trying to move the file, the command would fail. It needs to be fixed by doingmv --Most of the shell built-in commands and GNU tools support this option. Also POSIX recommends this too. See it from one of their guidelines. See POSIX Utility Conventions - Guideline 10