–nt file test operator in bash


File based con­di­tion for if state­ments in bash

Con­di­tion:

[ new­er­file –nt olderfile ]

Descrip­tion:

newerfile was changed more recently than olderfile, or if newerfile exists and olderfile doesn’t.

Exam­ple:

if [ file1.txt -nt file2.txt ]; then
    echo "file1.txt is newer than file2.txt;"
fi

Fur­ther Reading


You may also like...