How to do <cmd> file | hold file (now cp)

Leslie Mikesell les at chinet.chi.il.us
Thu Sep 13 05:33:57 AEST 1990


In article <19911:Sep1113:47:2290 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:

>No. That is not what cp does. cp copies a file with one name into a new
>file with a different name.

Not my cp.  Mine recognizes existing files.

>> The other
>> semantics associated with a file (i.e the contents of the inode) are
>> associated with the name, which is not being changed.

>What are you talking about? The filename has absolutely nothing to do
>with the contents of the inode; it's just a way of finding the inode.

Exactly: you find the inode and it's associated information by its
name.  Using an existing name means that you want to refer to the
inode associated with that name.

>Huh? ln is the program that associates a name with a different inode.

No, ln associates a different name with a particular inode that can
also be found with an existing name.

>Let me put it this way: If you had two programs, cp (copy) and rp
>(replace), the first with unlink/create and the second with over-write,
>which would you end up using almost all the time? The only time the
>semantics of rp would be proper would be when you really were replacing
>the old version of a file with a new version---but there's a program
>called ``install'' that was designed to do this job.

I would always use the over-writing version, because if I have a file
of a certain name, then I have already set the ownership, permissions,
and hard links the way they should be for a file of that name.  When
I cp something to that name, I just want to replace the contents.
For a more philosophical approach: I like commands to be as consistant
as possible under all conditions.  If you cp a file to a device or
FIFO, would you like to have the special file unlinked and the name
re-used for something else?

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.shell mailing list