moving files with mv

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Kurt Granroth
Date:  
Subject: moving files with mv
On Thursday, August 14, 2003, at 03:56 PM, Thomas Cameron wrote:

> ----- Original Message -----
> From: "Craig White" <>
>> If I use the command such as:
>>
>> mv DGN ../files-no-backup/ -R -p
>>
>> is it at all possible that these files may be lost because of a
>> character within the file name that is legal on Windows isn't legal on
>> Linux and thus, isn't copied? Is that just a Macintosh gotcha?
>
> It can happen for either OS - I've seen 'Doze users name a file
> something
> like:
>
> My silly long file name (January report).doc
> Contact info for Joseph "Joe" Smith.doc
>
> In either case the parentheses or quotes can really screw with Linux.
> My
> advice - use tar, not mv or cp:
>
> cd /path/to/source
> tar c * | taxf - -C /path/to/destination
>
> This seems to handle it better, and keeps ownership straight.


Hrm.. while 'tar' is certainly a valid choice, I think it's overkill
for this case. Using 'tar' to recursively COPY entire directories
instead of using 'cp' makes sense since it does a better job of
preserving everything. However, 'mv' shouldn't ever have a problem
with any legal files.

And yes, those files with parentheses and quotes are just fine under
Linux. Any decent shell will take care of escaping everything that
needs escaping.

ANYWAY, if you are going to use 'tar' to recursively copy the
directories, then according to the Tips HOWTO, it's better to use the
following form to not accidently hose the directory in case of error:

(cd /source/directory && tar cf - . ) | (cd /dest/directory && tar xvfp
-)