symbolic link: find all files that link to this file

前端 未结 3 1391
挽巷
挽巷 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:35

    I prefer to use the symlinks utility, which also is handy when searching for broken symlinks. Install by:

    sudo apt install symlinks
    

    Show all symlinks in current folder and subfolders:

    symlinks -rv .
    
    • -r: recursive
    • -v: verbose (show all symlinks, not only broken ones)

    To find a specific symlink, just grep:

    symlinks -rv . | grep foo.txt
    

提交回复
热议问题