Koozali.org: home of the SME Server
Contribs.org Forums => General Discussion => Topic started by: kevinb on November 16, 2008, 06:48:59 AM
-
Hello everyone,
I have a general Linux question and since SME is my first venture into Linux …. I do not know where else to go.
I have a directory structure
/a/b/c/1
/a/b/c/2/4
/a/b/c/3/5/6
I would like to copy the relative directories only starting from “/1/2/3" and then create hard links to the files in the directories. So I would have:
/x/1
/x/2/4
/x/3/5/6
With only hardlinks.
How can I do this from the CLI (via a cron job, the directories and files will be changing daily)?
Thank you in advance for your help.
Kevin
-
try rsync with the --dest-link option, something like this:
rsync -a --link-dest=/a/b/c /a/b/c/ /x
-
I have a directory structure
/a/b/c/1
/a/b/c/2/4
/a/b/c/3/5/6
I would like to copy the relative directories only starting from “/1/2/3" and then create hard links to the files in the directories. So I would have:
/x/1
/x/2/4
/x/3/5/6
With only hardlinks.
Alternatively:
cd /a/b/c
find . -type d | cpio -dp /x
find . -type f -exec ln {} /x/{} \;
-
Thanks for the suggestions everyone.
I just discovered that when you change the permission on a hard link it changes the permissions for all the hard links. No good for me. I will use rync and copy files.
-
I just discovered that when you change the permission on a hard link it changes the permissions for all the hard links. No good for me. I will use rync and copy files.
Links are just directory entries. The permissions apply to the files themselves, not to the various directory entries which reference the file.
-
That would explain it, thanks.
I am now pursuing another method. I am searching each file for a string and then copying these files to another folder. I can find the files but have not been able to pass the output to "cp" or "rsync". I have gotten this to work:
find <source> -name '*<file name string>*' -print | xargs grep -lirs '<text string 1>' /dev/null
This gives me a list of all the files that have <file name string> in the file name and contain <text string 1>.
- How can I have it find all the files that contain <text string 1> or <text string 2>?
- How can I have the command copy these files to another folder?
Thank you very much for your help. I realize that my question is out of the context of this forum and I appreciate the time spent to review this.
Kevin