[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unexpected behavior in mv
From: |
Mario J. Borgnia |
Subject: |
Unexpected behavior in mv |
Date: |
24 Apr 2003 16:07:59 -0400 |
Hi,
I was surprised when I gave mv a list (using *) as a source and no
destination. The result was that all files were moved to the last
directory in the list. Is this the expected behavior?
Example and steps to reproduce
address@hidden tmp]$ echo foo > foo
address@hidden tmp]$ echo bar > bar
address@hidden tmp]$ mkdir eenie
address@hidden tmp]$ mkdir meenie
address@hidden tmp]$ ls -l
total 16
-rw-r--r-- 1 me users 4 Apr 24 15:50 bar
drwxr-xr-x 2 me users 4096 Apr 24 15:50 eenie
-rw-r--r-- 1 me users 4 Apr 24 15:50 foo
drwxr-xr-x 2 me users 4096 Apr 24 15:56 meenie
address@hidden tmp]$ mv *
address@hidden tmp]$ ls -l
total 4
drwxr-xr-x 2 me users 4096 Apr 24 15:56 meenie
Thinking it over, it makes sense, everything was moved to the end of the
list. Although I find this a little bit disturbing.
This other case is MUCH more disturbing
address@hidden tmp]$ ls -l
total 8
-rw-r--r-- 1 me users 4 Apr 24 15:50 bar
-rw-r--r-- 1 me users 4 Apr 24 15:50 foo
address@hidden tmp]$ mv *
address@hidden tmp]$ ls -l
total 4
-rw-r--r-- 1 me users 4 Apr 24 15:50 foo
In this case bar overwrote foo. SCARY...
In case this is the intended behavior, is there any way of protecting
from this?
I guess I would gain partial protection by always using the -i flag
Thanks.
--
Mario J. Borgnia <address@hidden>
- Unexpected behavior in mv,
Mario J. Borgnia <=