filenames starting with a '-'

plug@arcticmail.com plug@arcticmail.com
Sun, 29 Oct 2000 12:34:50 -0700


I believe that it depends on the particular executable.
In other words, it depends on cp or mv's command-line
processing code, not on the shell you're using.  Anyway,
a double-hyphen ("--") is oftentimes used to indicate
to the executable that it should stop processing
switches/options.

In your case, you should be able to do something like

     mv  -i   --  -001 foo-001
         ^^   ^^
          \    \___ stop processing switches
           \
            \____ -i (interactive) switch


To find out for sure, take a gander at mv's source code
and getopt's source code.

For files or dirs with REALLY interesting names (like control
characters or extended ASCII characters), find's "-inum"
(to match on a particular inode number) can usually do the
trick.  To determine an inode's inode number, use "ls -li".


$ date > -001

$ ls -li
total 1
  75841 -rw-rw-r--    1 foo   bar         29 Apr  1 04:01 -001
  ^^^^^
     \___ The inode number of regular file "-001" is 75841

$ find . -xdev -inum 75841 -exec mv {} rubles4source \;

$ ls -li
total 1
  75841 -rw-rw-r--    1 foo   bar         29 Apr  1 04:01 rubles4source


D

* On Sat, Oct 28, 2000 at 10:12:12PM -0700, Don Harrop wrote:
> I was using gphoto to get some images form a camera and didn't assign a
> default filename to prefix the -001 -002 -003... etc..  Now I've got a
> bunch of filenames that start with a '-' and when I use cp or mv on the
> files it thinks that it's an option instead of a file.  Is there an
> undocumented option that will make cp/mv realize that it's dealing with a
> file?  There are other ways to solve the problem but I'd like to know how
> to do it with cp/mv...
> 
> Don