Search code examples
shellunixstat

How to get just modification date and time of a file using stat?


I use Stat command to to find the last modification date of a file and result is:

File: ‘first.php’
      Size: 145         Blocks: 8          IO Block: 4096   regular file
    Device: 801h/2049d  Inode: 1771067     Links: 1
    Access: (0664/-rw-rw-r--)  Uid: ( 1000/      fn)   Gid: ( 1000/      fn)
    Access: 2017-02-28 12:44:32.853785914 +0330
    Modify: 2017-02-27 23:22:11.280625946 +0330
    Change: 2017-02-27 23:22:11.344625946 +0330
     Birth: -

What command should I use to show just first.php 2017-02-27 23:22:11.280625946 +0330 in output?


Solution

  • Try reading the manual page:

    man stat
    

    And then use the format option:

    stat -c '%n %y'