Question related to symbolic links and copying

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question


















  • 1




    man find and check the options for -type
    – roaima
    Apr 3 at 14:36














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.







share|improve this question


















  • 1




    man find and check the options for -type
    – roaima
    Apr 3 at 14:36












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.







share|improve this question














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.









share|improve this question













share|improve this question




share|improve this question








edited Apr 3 at 15:45









Patrick Mevzek

2,0131721




2,0131721










asked Apr 3 at 14:31









user284144

82




82







  • 1




    man find and check the options for -type
    – roaima
    Apr 3 at 14:36












  • 1




    man find and 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










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).






share|improve this answer




















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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).






share|improve this answer




















  • 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














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).






share|improve this answer




















  • 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












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).






share|improve this answer












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).







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 3 at 15:00









hhoke1

31416




31416











  • 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















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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)