Some simple questions

Conor P. Cahill cpcahil at virtech.uucp
Mon Nov 27 22:43:01 AEST 1989


In article <21408 at usc.edu>, rkumar at buddha.usc.edu (Anon) writes:
> Here are some questions related to file management under UNIX.
> 
> 1) dir-a and dir-b are two directories. Both may have files
> 	with same names. How does one move the latest versions
> 	of the files from dir-b to dir-a? In other words, I
> 	want

Using cpio:

		cd dir-b
		find . -print | cpio -pdv dir-a

> 2) Suppose that a text file f is being included (e.g., #include)
> 	in more than one source. What is, if there is, a mechanism to
> 	protect file f from being accidentally deleted/modified?
> 	Preferably, rm, mv, etc should be able to detect
> 	if f is being used in some other file. The user may
> 	be expected to explicitly state that f is being used
> 	in source s when s is created.

The easiest way to do this (if you really want to) is to create a hard
link to the file in each directory that you wish to use it.  This way you
can remove it from whatever directory you want to and it will still be 
available where ever else it was linked to.

If you require this kind of operation in the same directory,  then look
before you remove.  (of course you could link the file to different 
entries in the same directory and have different source files include
different include files).

The best solution would be to have a separate include directory wherein
this file is placed and never removed (similar to /usr/include).


-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list