LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   'Stat' getting infro from a symlink (https://www.linuxquestions.org/questions/linux-newbie-8/stat-getting-infro-from-a-symlink-568159/)

khanrockz 07-10-2007 02:12 PM

'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 ?


Code:

[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.

wjevans_7d1@yahoo.co 07-10-2007 02:18 PM

Type the following at the command line:

Code:

man 1 stat
and all will be revealed.

Hope this helps.

khanrockz 07-10-2007 03:47 PM

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 ?

gilead 07-10-2007 09:57 PM

Is this what you want it to do?
Code:

stat -L /iso | grep Modify | awk {'print $2 $3 $4'}


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