Print a file’s last modified date in Bash

Print a file’s last modified date in Bash

Asked on December 20, 2018 in Bash.
Add Comment


  • 3 Answer(s)

    This is the simple and fastest solution,

    Here, we are use the command something called stat,

    stat -c %y "$entry"
    

    Additionally,

    %y time of last modification, human-readable
    
    Answered on December 20, 2018.
    Add Comment

    To get the solution faster, we simply use date command instead of stat ,awk and so on.

    date -r <filename>
    
    

    For date formatting look and use the man page;

    An example with common date and time format is here.

    date -r <filename> "+%m-%d-%Y %H:%M:%S"
    
    
    Answered on December 20, 2018.
    Add Comment

    Use the stat command is always better,

    stat -c%y Localizable.strings | cut -d'.' -f1
    
    
    Answered on December 20, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.