LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Script to find symlink (https://www.linuxquestions.org/questions/linux-general-1/script-to-find-symlink-4175485849/)

circus78 11-25-2013 03:01 PM

Script to find symlink
 
Hi,

I've a folder with several (broken) links.
How can I quickly find (in bash) the correct ones?

TB0ne 11-25-2013 03:16 PM

Quote:

Originally Posted by circus78 (Post 5070498)
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....

suicidaleggroll 11-25-2013 05:08 PM

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?

unSpawn 11-25-2013 05:53 PM

...or see 'man symlinks'?


All times are GMT -5. The time now is 02:44 AM.