04-05-2008
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
8 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How can I find all symbolic links across the network to a directory (2 Replies)
Discussion started by: mehtad
2 Replies
2. UNIX for Dummies Questions & Answers
how do i get the list of symbolic link names for a particular file programatically (4 Replies)
Discussion started by: b_u_n_1234
4 Replies
3. Shell Programming and Scripting
Hi all,
I have several links to a file. Is there any command or anyway to get all those links.
Thanks in advance
-Chanakya (3 Replies)
Discussion started by: Chanakya.m
3 Replies
4. UNIX for Dummies Questions & Answers
How would one find and list all links in a file system? My situation is
that I built several servers for disaster recovery, mirror images of
several servers in our main location. Instead of doing a "ls -l" on every
file system down the /usr structor to verify that I have all the necessary
links... (3 Replies)
Discussion started by: ruger14
3 Replies
5. UNIX for Dummies Questions & Answers
ls -l shows the number of links for each file. Is there a command that will show the link sources for a specific file? Running find on the entire filesystem and doing a little Perl "magic" is the only method I'm aware of. I'm running SunOS 5.8.
Thanks. (6 Replies)
Discussion started by: effigy
6 Replies
6. Shell Programming and Scripting
Hi,
I would like to do a scripting for finding the links based on the name I have and replace the links with the new name. General find command lists everything for that links ( means all the sub-sirs and all the files), i need only the main link and replace.
Can you anyone give me some... (1 Reply)
Discussion started by: rrb2009
1 Replies
7. Solaris
When loooking at files in a directory using ls, how can I tell if I have a hard link or soft link? (11 Replies)
Discussion started by: Harleyrci
11 Replies
8. AIX
Hi
I'm logged in as root in an aix box
Which command will list all the soft links and hard links present in the server ? (2 Replies)
Discussion started by: newtoaixos
2 Replies
smrsh(1M) System Administration Commands smrsh(1M)
NAME
smrsh - restricted shell for sendmail
SYNOPSIS
smrsh -c command
DESCRIPTION
The smrsh program is intended as a replacement for the sh command in the prog mailer in sendmail(1M) configuration files. The smrsh program
sharply limits commands that can be run using the |program syntax of sendmail. This improves overall system security. smrsh limits the set
of programs that a programmer can execute, even if sendmail runs a program without going through an alias or forward file.
Briefly, smrsh limits programs to be in the directory /var/adm/sm.bin, allowing system administrators to choose the set of acceptable com-
mands. It also rejects any commands with the characters: ,, <, >, |, ;, &, $,
(<RETURN>), or
(<NEWLINE>) on the command line to pre-
vent end run attacks.
Initial pathnames on programs are stripped, so forwarding to /usr/ucb/vacation, /usr/bin/vacation, /home/server/mydir/bin/vacation, and
vacation all actually forward to/var/adm/sm.bin/vacation.
System administrators should be conservative about populating /var/adm/sm.bin. Reasonable additions are utilities such as vacation(1) and
procmail. Never include any shell or shell-like program (for example, perl) in the sm.bin directory. This does not restrict the use of
shell or perl scrips in the sm.bin directory (using the #! syntax); it simply disallows the execution of arbitrary programs.
OPTIONS
The following options are supported:
-c command
Where command is a valid command, executes command.
FILES
/var/adm/sm.bin directory for restricted programs
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsr, SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
sendmail(1M), , attributes(5)
SunOS 5.10 6 Nov 1998 smrsh(1M)