Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Time stamp of a file

Using Bash shell script how to test if the file has been modified by checking the time stamp of the file.

Thanks.

Comments

  • abcabc Member Posts: 443
    : Using Bash shell script how to test if the file has been modified by checking the time stamp of the file.
    :
    : Thanks.
    :

    to get just the timestamp use
    [code]
    /bin/ls -l $1 | cut -b44-55
    [/code]

    to test for changes you can try something like:
    [code]
    #!/bin/sh

    if test -N $1; then
    echo "exists and has changed since read"
    :
    else
    if test -a $1; then
    echo "not changed"
    :
    else
    echo "not existing"
    fi
    fi
    [/code]
    to test against the last read time. afaik the creation time isn't stored.
  • Andre YoungAndre Young USAMember Posts: 0

    ________ [ http://forcoder.org ] free video tutorials and ebooks about | Go Assembly Visual Basic PL/SQL Delphi MATLAB Perl PHP C Scratch Visual Basic .NET Swift C++ Ruby Python R JavaScript Java Objective-C C# COBOL VBScript LabVIEW Scala Scheme FoxPro SAS ABAP Lisp D F# Awk Clojure Transact-SQL Alice Rust ML Logo Julia Prolog Erlang Dart Kotlin Hack Fortran Bash Ada Lua Crystal Apex | _

Sign In or Register to comment.