On Fri, 28 Sep 2007 16:33:23 -0400 "Miner, Jonathan W (CSC) (US SSA)" <jonathan.w.miner@xxxxxxxxxxxxxx> wrote: > > > > -----Original Message----- > From: fedora-list-bounces@xxxxxxxxxx on behalf of Zoltan Szabo > Sent: Fri 09/28/2007 04:08 PM > To: For users of Fedora > Cc: > Subject: all softlinks to a given file > > Do you know an easy (fast) way to find all the softlinks to a given > file, using Fedora? > > Example: in case of "S1 -> F, ...., SN -> F" the task is to find > S1, ..., SN given file F. > > Any idea is appreciated, > ---------------------------- > > Tough question... since links are one way... Here are some > thoughts. Assuming that you're only looking at one filesystem, try > to look at the inode numbers. Here is the initial directory listing: > > % ls -li > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 F > 3815193 lrwxrwxrwx 1 jminer iis 1 Sep 28 16:22 S1 -> F > 3815215 lrwxrwxrwx 1 jminer iis 11 Sep 28 16:23 S2 -> ../jminer/F > > The first number is the inode, and the file and each link has a > distinct inode number. Modify the args to `ls` and you can derefernce > the symbolic link: > > % ls -Lli > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 F > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 S1 > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 S2 > > So you would have to traverse your filesystem looking for links (S#) > that derefernce to the same inode as the known file (F). You can do > this with `find` > > % find . -type l -exec ls -Lli {} \; | awk '$1 == 3815190 {print $0}' > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 ./S1 > 3815190 -rw-r--r-- 1 jminer iis 0 Sep 28 16:21 ./S2 > Thank you for both solutions: 1) find . -lname F 2) ls -Lli % => inode number: 3815190 find . -type l -exec ls -Lli {} \; | awk '$1 == 3815190 {print $0}' In case of "SN -> .... -> S2 -> S1 -> F <- SB1": 1): returns "S1" and "SB1" (first-level solutions), 2): returns "SN",...,"S2","S1" and "SB1" (all-level solutions). For me, 1) is enough, but it was instructive. Thanks again, Z. -- fedora-list mailing list fedora-list@xxxxxxxxxx To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list