ugh.book

(singke) #1

276 The File System


Moving Your Directories
Historically, Unix provides no tools for maintaining recursive directories
of files. This is rather surprising, considering that Unix (falsely) prides
itself on having invented the hierarchical file system. For example, for
more than a decade, Unix lacked a standard program for moving a direc-
tory from one device (or partition) to another. Although some versions of
Unix now have a mvdir command, for years, the standard way to move
directories around was with the cp command. Indeed, many people still use
cp for this purpose (even though the program doesn’t preserve modifica-
tion dates, authors, or other file attributes). But cp can blow up in your
face.
Date: Mon, 14 Sep 92 23:46:03 EDT
From: Alan Bawden <[email protected]>
To: UNIX-HATERS
Subject: what else?

Ever want to copy an entire file hierarchy to a new location? I wanted
to do this recently, and I found the following on the man page for the
cp(1) command:

NAME


cp - copy files
...
cp -rR [ -ip ] directory1 directory2
...
-r
-R Recursive. If any of the source files are directories, copy the
directory along with its files (including any subdirectories
and
their files); the destination must be a directory.
...

Sounds like just what I wanted, right? (At this point half my audience
should already be screaming in agony—“NO! DON’T OPEN THAT
DOOR! THAT’S WHERE THE ALIEN IS HIDING!”)

So I went ahead and typed the command. Hmm... Sure did seem to
be taking a long time. And then I remembered this horror from fur-
ther down in the cp(1) man page:

BUGS
cp(1) copies the contents of files pointed to by symbolic links.
It does not copy the symbolic link itself. This can lead to
Free download pdf