In article <1kjkg7v.jeejrp1jht36qN%>,
ure (Richard Maine) wrote:
> Jim Gibson <> wrote:
>
> > Try running the file utility on the file this way using the Terminal
> > command-line in your home directory (where 'ls' shows the file):
> >
> > cat > file.txt
> > -format
> > ^D
> >
> > (where ^D is Control-D: holding the control key while typing d)
> >
> > file -f file.txt
> >
> > Note that the above manipulations are necessary because the string
> > -format will be interpreted by most command-line utilities as an option
> > and not as a file name. Even surrounding the string in quotes will not
> > help, as that just protects the string from interpretation by the shell.
> > Fortunately the file utility has the ability to read file names from an
> > auxiliary file. Hence the above will work.
>
> A much simpler workaround to avoid unintended interpretation of file
> names like that as switches is to use a pathname instead of a simple
> file name. In this case, do something like
>
> file ./-format
>
> where the "." means current directory. This trick of prefixing a file
> name with "./" to specify it as a path gets used in lots of contexts.
> For example, that's the usual trick to run an executable from the
> current directory if you avoid having the current directory in your PATH
> environment variable. This is done a lot by people doing development
> work.
Thanks, I should have thought of that approach. Another method would be
to use the full path (' file /User/myname/-format'), which is easy to do
in Terminal by typing 'file ' (with a space) and then dragging an icon
of the file from a Finder window into the Terminal window.