LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-29-2009, 09:47 AM   #1
kinny
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Rep: Reputation: 0
Finding a softlink


Hi ,
Does anyone know how to find if a file is a softlink or not.
I have to print the file name that the softlink is pointing to. Is this possible?
 
Old 10-29-2009, 09:49 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
This will show you if a file is a soft link:
Quote:
ls -l somefile
This will show you the actual file the link points to:
Quote:
ls -lL somefile
 
Old 10-29-2009, 10:00 AM   #3
kinny
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Well... is it possible to find it with an if statement for I have to take some actions if the file is a symbolic link or otherwise.
Thanks in advance
 
Old 10-29-2009, 10:16 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
[ -L something ]
"[.....]" is a synonym for "test"

"man test" for all the details

So it would be something like this:

if [ -L something ]; then
do stuff
fi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help create a softlink gate Linux - Newbie 1 03-20-2009 10:39 PM
Softlink Modem not recognized under SuSE10.1 fliplip Linux - Hardware 2 12-20-2006 05:32 PM
softlink /boot max_mad SUSE / openSUSE 3 04-13-2006 02:53 AM
Installing softlink to java? usernameddr Mandriva 5 02-04-2005 01:47 PM
Cannot create Linux softlink on smbfs neqboan Linux - General 0 07-30-2003 02:21 PM


All times are GMT -5. The time now is 10:23 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration