Francesco

> foscolo:~ # ls -l "-"
> -rw-r--r--   1 root     root            6 gen 14 11:55 -
> foscolo:~ # ls -l "-*"
> ls: invalid option -- *
> Try `ls --help' for more information.
> foscolo:~ # ls -l "-\*"

This is an almost standard answer to your question.

As you noted since the file name begins with a '-' it looks like an
option to the command.  You need to force it to not look like an
option.  Put a ./ in the front of it.  Or give it the full file name
path.  Or tell the command you are through with options.

  ls ./-stuff
  ls /full/path/-stuff
  ls -- -stuff

> And, cp with making non-existent directory?

This is generally a common behavior for most UNIX programs that
contain options.  The -- is a common behavior for most programs but
unfortunately there are different standards that different programs
follow.  But one of the two should always be sufficient for robust
operation.  As you found out 'cp' follows the same rules that 'ls'
does.  Note that any character is valid in file names except for '/'
and the null character.  But that freedom to include spaces,
characters that are traditionally option characters, etc. means more
learning is needed to understand how to work with them.

Hope this helps

Bob Proulx

Reply via email to