Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, I think this can be done but not sure how, i have a folder which is symbolically linked to in multiple places on my server (links created using ln ...
  1. #1
    Just Joined!
    Join Date
    Apr 2003
    Posts
    52

    how to get report of symbolic link locations

    Hi, I think this can be done but not sure how,

    i have a folder which is symbolically linked to in multiple places on my server (links created using ln -s)

    what I want to do is get a print of all of the symbolic link locations that link to that folder (or file)

    is this possible?

    Thanks!

  2. #2
    Just Joined!
    Join Date
    Jan 2009
    Location
    Hyderabad(India)
    Posts
    23

    Smile

    I am giving you a solution,
    first change to root directory
    cd /
    Then, i am assuming your file name is file1,for which you wanted to see symbolic links,so

    ls -lR / | grep "[->] file1"

    Now you must see a list,but it is possible that file names may be similar,here comes the final point,as the very first step you say
    ls -l file1 > temp
    Now temp contains the info about your file,use this to contrast between link to your file and link to other file that has the same name.
    I am sure at least time flags will differ,which will make your job easy.
    Anyway try to do it,there is a hidden bug,can you notice??

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Location
    Hyderabad(India)
    Posts
    23

    Smile

    Simplest way:
    find / -lname filename -print
    The second argument / indicates to search entire file system
    Or if you want to supress any error messages,then say


    find / -lname filename -print 2>err >op
    Errors are redirected to err(file created automatically)
    whole output will be sent to op(again a file)
    You can omit >op to see thee output on screen
    But i recommend you to run this whole thing in background(use & at the end)
    and continue with your work,because this thing may take anywhere from 15 mins to 45 minutes,depending on number of files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...