The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk script to search an html file and output links kyris Shell Programming and Scripting 8 05-11-2008 05:25 AM
Listing all links in a file system ruger14 UNIX for Dummies Questions & Answers 3 02-21-2007 09:39 AM
How to get all the links of a file? Chanakya.m Shell Programming and Scripting 3 08-22-2006 03:09 AM
Symbolic Links for a File b_u_n_1234 UNIX for Dummies Questions & Answers 4 03-06-2002 12:58 PM
Finding symbolic links mehtad UNIX for Dummies Questions & Answers 2 11-15-2001 06:26 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-05-2008
ohagar ohagar is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 16
finding links to a file

I am writing a shell script that needs to files that are links to on specific shell script.

e.g.

/usr/bin/a.sh

/home/mydir/a.sh --> /usr/bin/a.sh
/home/yourdir/a.sh --> /usr/bin/a.sh
/home/hisdir/a.sh --> /usr/bin/a.sh
/home/herdir/a.sh --> /usr/bin/a.sh

I know I can set myself at the /home and "find" the links, but my question is more to the guru types. Is there a simple command that I can use on /usr/bin/a.sh to get the list of all the files that have links to it?
It might give output like:

# lnk2file /usr/bin/a.sh
/home/mydir/a.sh
/home/yourdir/a.sh
/home/hisdir/a.sh
/home/herdir/a.sh
#

Just want to know if there is a better way to skin this cat.

TIA

hagar
  #2 (permalink)  
Old 04-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If you think about how links are implemented, I would say the generic answer is no. Hard links are just directory entries in different places which link to the same inode number; there is no link in the other direction. Similarly, symbolic links are typically just a text snippet which says where to link to, and a special flag in the directory entry tells the kernel to read the file and redirect to the file pointed to by the text snippet. Again, there is no link in the other direction.
  #3 (permalink)  
Old 04-06-2008
ohagar ohagar is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 16
Thank you for the new knowledge you have given me re: how links actually work.

hagar
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0