Re: Finding all the links in a Unix file/directory path
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Wed, 13 May 2009 03:13:06 +0100
Quoth Jürgen Exner <jurgenex@xxxxxxxxxxx>:
John <freesoft12@xxxxxxxxx> wrote:
Looks like my question was not clear:
In my logfile, i see the following path: /tmp/test_hier/b/f/of3.cpp.
Since directory 'f' is a symbolic link to directory 'c', the actual
path is /tmp/test_hier/b/c/of3.cpp.
I want to copy the orig path /tmp/test_hier/b/f/of3.cpp to my target
directory: /tmp/copy/ . here is what I want to do:
1) Copy the actual file /tmp/test_hier/b/c/of3.cpp as /tmp/copy/tmp/
test_hier/b/c/of3.cpp
2) Create a link: /tmp/copy/tmp/test_hier/b/f -> /tmp/copy/tmp/
test_hier/b/c
So, if I understand correctly you want to copy the complete _structure_
of the the file tree, i.e. if a directory entry was a symlink in the
original then it should become a symlink in the copy, too.
No, AIUI he doesn't want to copy the whole tree, just one file and all
symlinks required to resolve that. So if he starts with
/a/b -> /c
/c/d -> /e
/e/f
/g -> /a/b/d/f
and copys /g to /tmp/copy he wants to end up with
/tmp/copy/
a/
b -> /tmp/copy/c
c/
d -> /tmp/copy/e
e/
f
g -> /tmp/copy/a/b/d/f
In particular, he seems to want to follow and copy links that point
anywhere on the filesystem, without copying the whole disk. This is not
straightforward, but can be done with -l, readlink,
File::Basename::dirname, and a little care.
Ben
.
- References:
- Finding all the links in a Unix file/directory path
- From: freesoft12@xxxxxxxxx
- Re: Finding all the links in a Unix file/directory path
- From: smallpond
- Re: Finding all the links in a Unix file/directory path
- From: John
- Re: Finding all the links in a Unix file/directory path
- From: Jürgen Exner
- Finding all the links in a Unix file/directory path
- Prev by Date: Re: Simple date question
- Next by Date: Re: Simple date question
- Previous by thread: Re: Finding all the links in a Unix file/directory path
- Next by thread: Re: Finding all the links in a Unix file/directory path
- Index(es):
Relevant Pages
|