LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-13-2005, 02:53 AM   #1
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Rep: Reputation: 30
How to search for files that are symbolic links pointing to a particular file?


Eg. Both /home/user1/file1 and /home/user2/file2 are files that are symbolic links to /etc/init.d/testscript.

Is there a command that can search for all files that are symbolic links pointing to /etc/init.d/testscript? For this example, results should be returning /home/user1/file1 and /home/user2/file2.

Thanks.
 
Old 10-13-2005, 07:32 AM   #2
blindcoder
ROCK Linux
 
Registered: Dec 2003
Location: Berlin, Germany
Distribution: Crystal ROCK
Posts: 108

Rep: Reputation: 15
You can try something like this:
Code:
find / -type -l | while read link ; do
readlink ${link} | grep -q testscript && echo ${link}
done
You can substitute "find /" with "find <whereveryouwanttosearch>" and "testscript" with whatever filename the links should point to.

Greetings,
Benjamin
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
symbolic links durden2.0 Linux - Newbie 6 11-12-2008 03:06 AM
How to find all symbolic links pointing to a particular file? Akhran Linux - Newbie 5 11-19-2005 06:25 AM
Symbolic links? TongueTied Linux - Newbie 3 08-27-2003 06:00 AM
symbolic links winger Linux - General 5 04-06-2002 05:16 PM
Symbolic links Valerie Linux - Newbie 12 03-31-2002 01:49 AM


All times are GMT -5. The time now is 01:04 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration