LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-25-2013, 03:01 PM   #1
circus78
Member
 
Registered: Dec 2011
Posts: 273

Rep: Reputation: Disabled
Script to find symlink


Hi,

I've a folder with several (broken) links.
How can I quickly find (in bash) the correct ones?
 
Old 11-25-2013, 03:16 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Thumbs up

Quote:
Originally Posted by circus78 View Post
Hi,
I've a folder with several (broken) links. How can I quickly find (in bash) the correct ones?
Start by reading the man page on find...pay particular attention to the -type flag. What have you done/tried so far?? A very simple bash script would take a couple minutes:
Code:
if [ ! -L foo ]; then
  do something
fi
There are SEVERAL flags that find has that deal with symlinks....
 
Old 11-25-2013, 05:08 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Please clarify your question.

You have a folder with several broken links. A broken link means that it's a symbolic link that points to a file that does not exist. Now you want to find the correct "ones". Which "ones"? What does that mean? Are you trying to find unbroken links? The updated name/location of the target of your broken links?

Last edited by suicidaleggroll; 11-25-2013 at 05:09 PM.
 
Old 11-25-2013, 05:53 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...or see 'man symlinks'?
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find symlink target name in script germanyzulu Linux - Software 4 08-14-2015 10:23 AM
How to find symlink? kaz2100 Linux - Software 10 09-25-2014 12:41 PM
can not find root file. create symlink anon222 Fedora - Installation 2 11-04-2009 07:39 AM
Symlink will not execute Shell Script in /etc/rc2.d netwrkengeer Linux - Software 4 08-03-2008 03:35 PM
Can't get script to run from symlink in etc/init.d goggyturk Debian 5 12-05-2006 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration