Monday, May 6, 2024
48
rated 0 times [  48] [ 0]  / answers: 1 / hits: 153523  / 3 Years ago, sat, may 22, 2021, 1:18:01

I had created many symbolic links on various paths for a particular file or a directory. I want the whole list of created symbolic links paths (location).


Example:


I created symbolic links for ~/Pictures directory on many directories. How do I list all the symlinks to that ~/Pictures directory?


Is that possible? If yes, then how?


More From » command-line

 Answers
1

Here is an example:



find -L /dir/to/start -xtype l -samefile ~/Pictures


or, maybe better:



find -L /dir/to/start -xtype l -samefile ~/Pictures 2>/dev/null


to get rid of some errors like Permission denied, Too many levels of symbolic links, or File system loop detected which find throws them when doesn't have the right permissions or other situations.




  • -L - Follow symbolic links.


  • -xtype l - File is symbolic link


  • -samefile name - File refers to the same inode as name. When -L is in effect, this can include symbolic links.




Notes:




  • Use lowercase L in -xtype l, not the digit 1.

  • On macOS / Darwin, -xtype is -type.


[#26694] Monday, May 24, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
trousransla

Total Points: 285
Total Questions: 112
Total Answers: 113

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
;