Visit Our UNIX and Linux User Community

Testing targets of link files > ln -s

Thread Tools Search this Thread
Operating Systems Solaris Testing targets of link files > ln -s
# 1  
Old 03-16-2009
Testing targets of link files > ln -s

Hi all

Ive been given the task to write a script that tests that certain link files work, i.e. the physical directory the link points too, is actually there.

Now, before I go down the route of ls -l | awk ...... or using test or find, is there a far more simpler command that I can use ?

Or, has anyone got a script that might help me out.

Great site by the way, often spent the odd hour or so going through messages as a guest, so decided to join :-)


SBK - Sussex - UK
# 2  
Old 03-16-2009
Re: testing targets os link file > ln -s

ls will show what the file is at the end of the symbolic link if you do:
$ ls -L ${FILENAME}

You could then capture the return code and respond accordingly:
if [ ${RESULT} -ne 0 ]; then
echo "We have a problem Houston, with ${FILENAME}."


Tony Fuller
# 3  
Old 03-17-2009
Cheers Tony,

Your a star. That really helped. :-)


Previous Thread | Next Thread
Test Your Knowledge in Computers #457
Difficulty: Easy
NTP was created to synchronize all participating computers to within a few milliseconds of Coordinated Universal Time (UTC).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

rm files after testing for successful scp

First off, I know this is sort of a rehash of similar questions that have been asked in other closed threads, but I haven't been able to figure out how to apply the answers provided in those threads to my scenario and make it work. I am working on a script in KSH on AIX 5.1 that will do a bulk... (1 Reply)
Discussion started by: derndingle
1 Replies

2. UNIX for Dummies Questions & Answers

testing if files exist

I am trying to test arguments to see if they are files in any directory. I have : but it's not working (7 Replies)
Discussion started by: skooly5
7 Replies

3. UNIX for Dummies Questions & Answers

Shell Command for Symbolic Link Targets

**DUP post in Shell Programming and Scripting *** Hello, I'm still learning the ins and outs of how to combine multiple Unix commands together (specifically AIX), but I'm looking to do the following (only on local files): 1. Find all symbolic links that are not set up using absolute... (3 Replies)
Discussion started by: bdizenhouse
3 Replies

4. UNIX for Dummies Questions & Answers

makefile Q about targets $@

Hi All I need to parse the target something like: ifeq '$@' 'first' echo 1 $@ endif ifeq '$@' 'second' echo 2 $@ endif The thing is to be able compare the target string to any string and then do the commands Thanks a lot ziv (0 Replies)
Discussion started by: zivsegal
0 Replies

5. Solaris

testing link on RSC card

I setup RSC on a 280R using the network connection. Unfortunately, I am unable to telnet to this card and I was wondering if there was a way to test the link from the rsc card. Here is my rsc configuration: machine1:/tmp/rsc# /usr/platform/SUNW,Sun-Fire-280R/rsc/rscadm show page_enabled="false"... (0 Replies)
Discussion started by: dangral
0 Replies

6. Shell Programming and Scripting

link files together

if I have 1000 files, named file1, file2, ... ,file1000. for each one, I want to append a line, for example "this is the end of file#". then, I want to link them all together. how can I do that by using a simple script? (1 Reply)
Discussion started by: fredao
1 Replies

7. Shell Programming and Scripting

testing for presence of files in ftp

I have a shell script which GETS a file, but I only want to run this script if $FILE exists on the remote host, don't know correct syntax.....please help ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWD bin get $FILE rename export.prn export.prn.$TIMESTAMP !cat... (0 Replies)
Discussion started by: walterja
0 Replies

8. UNIX for Dummies Questions & Answers

Link files....

How do you identify the type of a link in the output of the ls -l command? (1 Reply)
Discussion started by: Tom Bombadil
1 Replies

9. UNIX for Dummies Questions & Answers

Permissions on link files

Does any one now if you can change permissions on a linked file with out completely removing it and then relinking it? (2 Replies)
Discussion started by: moviestud80
2 Replies

10. Shell Programming and Scripting

Link files in unix

Can anyone say some ideas about using/creating link files (for ex., lrwxrwxrwx 1 bin bin 7 Jan 10 2001 bin -> usr/bin) in a shell script. (2 Replies)
Discussion started by: yuvasyntel
2 Replies

Featured Tech Videos