Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-10-2007, 02:12 PM   #1
LQ Newbie
Registered: Feb 2007
Posts: 13

Rep: Reputation: 0
'Stat' getting infro from a symlink

Hi guys !
I have a quick question. I have a symlink which points to file in directory. Now I need to run 'stat' on the original file. The symlink is dynamic and keeps on pointing to different locations in different times. But when I run 'stat' on this symlink it gives me the properties of the symlink , not the file it is pointing to. How can I get the modified date of the actual file it is pointing to rather than the symlink ? any ideas ?

[Testing: /tmp]$ stat /iso 
  File: `/iso' -> `/misc/2007.bin'
  Size: 46              Blocks: 0          IO Block: 4096   symbolic link
Device: 1h/1d   Inode: 4573        Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2007-07-10 11:10:48.817069000 +0000
Modify: 2007-07-10 10:36:52.633381000 +0000
Change: 2007-07-10 10:36:52.633381000 +0000

[Testing: /tmp]$ stat /misc/2007.bin 
  File: `/misc/2007.bin'
  Size: 38211864        Blocks: 74728      IO Block: 4096   regular file
Device: 801h/2049d      Inode: 14          Links: 1
Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2007-07-10 10:59:30.000000000 +0000
Modify: 2007-07-10 10:34:04.000000000 +0000
Change: 2007-07-10 10:34:04.000000000 +0000
You can see they are different.
Old 07-10-2007, 02:18 PM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Type the following at the command line:

man 1 stat
and all will be revealed.

Hope this helps.
Old 07-10-2007, 03:47 PM   #3
LQ Newbie
Registered: Feb 2007
Posts: 13

Original Poster
Rep: Reputation: 0
yeah ... thanks .. i got it .. its "stat -L <linkname>". Do you know how can I retrieve just modification date from it ? I mean using awk or anything , how can I get just the modified date ?
Old 07-10-2007, 09:57 PM   #4
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Is this what you want it to do?
stat -L /iso | grep Modify | awk {'print $2 $3 $4'}


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
Use of stat() in C rblampain Programming 3 06-02-2005 07:41 AM
Cannot stat??? chui_yap Linux - Newbie 1 01-04-2005 07:56 PM
cannot stat scottsteibel Linux - Newbie 2 12-11-2004 04:51 PM
stat warney_out Programming 1 09-28-2004 04:37 AM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 05:07 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:55 AM.

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