The UNIX and Linux Forums  

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
tar the symbolic link ganga.dharan Shell Programming and Scripting 1 05-23-2008 08:11 AM
Shell Command for Symbolic Link Targets bdizenhouse UNIX for Dummies Questions & Answers 3 02-21-2008 01:57 PM
need some info about symbolic link and hard link detective linux UNIX for Dummies Questions & Answers 2 01-08-2008 07:36 AM
[help] about symbolic link solaris 8 bucci SUN Solaris 1 10-12-2006 07:30 AM
symbolic Link bhargav UNIX for Dummies Questions & Answers 1 10-15-2004 10:41 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-21-2008
bdizenhouse bdizenhouse is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 5
Shell Command for Symbolic Link Targets (Posted in Unix for dummies as well)

**DUP post in Unix for dummies questions & answers***

Hello,

I'm trying to create a script to do the following:

1. Find all symbolic links that are not set up using absolute pathnames
2. Find all symbolic links that are broken (ie, target does not exist).

I would like each of these to be executed as a single command, as well as a duplicate command that will display the count of resulting matches.

I have done the following:
#2
find / -type l | (while read FN ; do test -e "$FN" || ls -l "$FN"; done)
and
find / -type l | (while read FN ; do test -e "$FN" || ls -l "$FN"; done) | grep -c '[a-z]'

#1
find / -type l | (while read FN ; do test -e "$FN" | file -h "$FN" | grep 'symbolic link to [^/]' ; done)
and
find / -type l | (while read FN ; do test -e "$FN" | file -h "$FN" | grep 'symbolic link to [^/]' ; done) | grep -c 'symbolic link to [^/]'

Are these correct? I want to make sure I'm only looking at local filesystems only. Also how can I suppress the messages like "ls: 0653-341 The file xxx does not exist." or "find: 0652-019 The status on xxx is not valid."


Thanks for any and all help.

Ben
 

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 12:58 PM.


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