symbolic link: find all files that link to this file

前端 未结 3 1390
挽巷
挽巷 2020-12-12 10:33

Hallo all, I need to do this in linux:

  • Given: file name \'foo.txt\'
  • Find: all files that are symbolic links to \'foo.txt\'

How to do it

3条回答
  •  心在旅途
    2020-12-12 11:15

    It depends, if you are trying to find links to a specific file that is called foo.txt, then this is the only good way:

    find -L / -samefile path/to/foo.txt
    

    On the other hand, if you are just trying to find links to any file that happens to be named foo.txt, then something like

    find / -lname foo.txt
    

    or

    find . -lname \*foo.txt # ignore leading pathname components
    

提交回复
热议问题