Question related to symbolic links and copying

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
So the following command copies from /source/allsubdirectroies (/usr/hdp/2.6.3.0-235) to a /target (/tmp/jar263) folder:
find /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ;
The problem for me is that in the source directory there are files with symbolic link, i.e.:
hadoop-nfs.jar -> hadoop-nfs-2.7.3.2.6.3.0-235.jar
So when I check my /tmp/jar263 folder I see the following file:
hadoop-nfs-2.7.3.2.6.3.0-235.jar
However what I want is the "hadoop-nfs.jar" name.
Any way to get the link name not the original name of the file?
There are many links in the usr/hdp/2.6.3.0-235/ folder/subfolder structure.
symlink
add a comment |Â
up vote
1
down vote
favorite
So the following command copies from /source/allsubdirectroies (/usr/hdp/2.6.3.0-235) to a /target (/tmp/jar263) folder:
find /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ;
The problem for me is that in the source directory there are files with symbolic link, i.e.:
hadoop-nfs.jar -> hadoop-nfs-2.7.3.2.6.3.0-235.jar
So when I check my /tmp/jar263 folder I see the following file:
hadoop-nfs-2.7.3.2.6.3.0-235.jar
However what I want is the "hadoop-nfs.jar" name.
Any way to get the link name not the original name of the file?
There are many links in the usr/hdp/2.6.3.0-235/ folder/subfolder structure.
symlink
1
man findand check the options for-type
â roaima
Apr 3 at 14:36
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
So the following command copies from /source/allsubdirectroies (/usr/hdp/2.6.3.0-235) to a /target (/tmp/jar263) folder:
find /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ;
The problem for me is that in the source directory there are files with symbolic link, i.e.:
hadoop-nfs.jar -> hadoop-nfs-2.7.3.2.6.3.0-235.jar
So when I check my /tmp/jar263 folder I see the following file:
hadoop-nfs-2.7.3.2.6.3.0-235.jar
However what I want is the "hadoop-nfs.jar" name.
Any way to get the link name not the original name of the file?
There are many links in the usr/hdp/2.6.3.0-235/ folder/subfolder structure.
symlink
So the following command copies from /source/allsubdirectroies (/usr/hdp/2.6.3.0-235) to a /target (/tmp/jar263) folder:
find /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ;
The problem for me is that in the source directory there are files with symbolic link, i.e.:
hadoop-nfs.jar -> hadoop-nfs-2.7.3.2.6.3.0-235.jar
So when I check my /tmp/jar263 folder I see the following file:
hadoop-nfs-2.7.3.2.6.3.0-235.jar
However what I want is the "hadoop-nfs.jar" name.
Any way to get the link name not the original name of the file?
There are many links in the usr/hdp/2.6.3.0-235/ folder/subfolder structure.
symlink
edited Apr 3 at 15:45
Patrick Mevzek
2,0131721
2,0131721
asked Apr 3 at 14:31
user284144
82
82
1
man findand check the options for-type
â roaima
Apr 3 at 14:36
add a comment |Â
1
man findand check the options for-type
â roaima
Apr 3 at 14:36
1
1
man find and check the options for -typeâ roaima
Apr 3 at 14:36
man find and check the options for -typeâ roaima
Apr 3 at 14:36
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
From man find, ubuntu manpages version:
-L Follow symbolic links. When find examines or prints information about files, the information used
shall be taken from the properties of the file to which the link points, not from the link itself
(unless it is a broken symbolic link or find is unable to examine the file to which the link
points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still
be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its
search, the subdirectory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always match against the type of the
file that a symbolic link points to rather than the link itself (unless the symbolic link is
broken). Using -L causes the -lname and -ilname predicates always to return false.
So find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ; should do the trick. Make sure to read the options under -type, as roaima suggested, if you run into any strange behavior (find may behave slightly differently on, e.g. OSX).
There's also the possibility of using-Lwithcpinstead of withfind, depending on what name one wants to have at the target.
â Kusalananda
Apr 3 at 15:07
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
From man find, ubuntu manpages version:
-L Follow symbolic links. When find examines or prints information about files, the information used
shall be taken from the properties of the file to which the link points, not from the link itself
(unless it is a broken symbolic link or find is unable to examine the file to which the link
points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still
be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its
search, the subdirectory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always match against the type of the
file that a symbolic link points to rather than the link itself (unless the symbolic link is
broken). Using -L causes the -lname and -ilname predicates always to return false.
So find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ; should do the trick. Make sure to read the options under -type, as roaima suggested, if you run into any strange behavior (find may behave slightly differently on, e.g. OSX).
There's also the possibility of using-Lwithcpinstead of withfind, depending on what name one wants to have at the target.
â Kusalananda
Apr 3 at 15:07
add a comment |Â
up vote
1
down vote
accepted
From man find, ubuntu manpages version:
-L Follow symbolic links. When find examines or prints information about files, the information used
shall be taken from the properties of the file to which the link points, not from the link itself
(unless it is a broken symbolic link or find is unable to examine the file to which the link
points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still
be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its
search, the subdirectory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always match against the type of the
file that a symbolic link points to rather than the link itself (unless the symbolic link is
broken). Using -L causes the -lname and -ilname predicates always to return false.
So find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ; should do the trick. Make sure to read the options under -type, as roaima suggested, if you run into any strange behavior (find may behave slightly differently on, e.g. OSX).
There's also the possibility of using-Lwithcpinstead of withfind, depending on what name one wants to have at the target.
â Kusalananda
Apr 3 at 15:07
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
From man find, ubuntu manpages version:
-L Follow symbolic links. When find examines or prints information about files, the information used
shall be taken from the properties of the file to which the link points, not from the link itself
(unless it is a broken symbolic link or find is unable to examine the file to which the link
points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still
be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its
search, the subdirectory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always match against the type of the
file that a symbolic link points to rather than the link itself (unless the symbolic link is
broken). Using -L causes the -lname and -ilname predicates always to return false.
So find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ; should do the trick. Make sure to read the options under -type, as roaima suggested, if you run into any strange behavior (find may behave slightly differently on, e.g. OSX).
From man find, ubuntu manpages version:
-L Follow symbolic links. When find examines or prints information about files, the information used
shall be taken from the properties of the file to which the link points, not from the link itself
(unless it is a broken symbolic link or find is unable to examine the file to which the link
points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still
be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its
search, the subdirectory pointed to by the symbolic link will be searched.
When the -L option is in effect, the -type predicate will always match against the type of the
file that a symbolic link points to rather than the link itself (unless the symbolic link is
broken). Using -L causes the -lname and -ilname predicates always to return false.
So find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp /tmp/jar263 ; should do the trick. Make sure to read the options under -type, as roaima suggested, if you run into any strange behavior (find may behave slightly differently on, e.g. OSX).
answered Apr 3 at 15:00
hhoke1
31416
31416
There's also the possibility of using-Lwithcpinstead of withfind, depending on what name one wants to have at the target.
â Kusalananda
Apr 3 at 15:07
add a comment |Â
There's also the possibility of using-Lwithcpinstead of withfind, depending on what name one wants to have at the target.
â Kusalananda
Apr 3 at 15:07
There's also the possibility of using
-L with cp instead of with find, depending on what name one wants to have at the target.â Kusalananda
Apr 3 at 15:07
There's also the possibility of using
-L with cp instead of with find, depending on what name one wants to have at the target.â Kusalananda
Apr 3 at 15:07
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f435295%2fquestion-related-to-symbolic-links-and-copying%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
man findand check the options for-typeâ roaima
Apr 3 at 14:36