Re: need help making hard link for a directory tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fedora-list@xxxxxxxxxxxxxx wrote:
I need to mirror a complex directory structure with hard links. Of course the directories themselves can not be hard linked, but is there a simple way to create a duplicate directory tree and then make hard links to all of the files?

The links are to provide ftp access to files in a chrooted area on the same partition.

Try this script. Run it from the top-level directly that you want to copy-by-linking, after setting the CHROOT value to the full pathname of the directory you want to create the copy in. This script will only link regular files, not symlinks, device files etc., but you should be able to modify it to do that fairly easily if you need to do that.


#!/bin/sh

# TEMPLATE directory is root of tree you want to replicate.
# It should *not* be an absolute pathname.
TEMPLATE=.

# CHROOT is absolute pathname of directory you want to clone the
# template to.
# It must be an absolute pathname and it must not be a subdirectory
# of the template directory.
CHROOT=/path/to/chroot

# Replicate directory structure
find $TEMPLATE -type d -exec mkdir -p $CHROOT/{} \;

# Make hard links to files
find $TEMPLATE -type f -exec ln {} $CHROOT/{} \;



Paul.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux