What is: do if [ $i -nt ${LOG_DIR_PATH}/test ]
What does -nt
do for this case?
LOG_DIR_PATH=/home/users/chinboon/test-chinboon/logs/sandbox1
do if 开发者_Go百科[ $i -nt ${LOG_DIR_PATH}/test ]
The -nt
flag checks if file $i
has a more recent modification date than file ${LOG_DIR_PATH}/test
.
See man 1 test
for all available flags.
I am pointing you to man test
since
if [ $i -nt ${LOG_DIR_PATH}/test ]; then
# SOMETHING
fi
is a shorthand for
if test $i -nt ${LOG_DIR_PATH}/test; then
# SOMETHING
fi
According to IBM DeveloperWorks the purpose if -nt
is to
Test if file1 is newer than file 2. The modification date is used for this and the next comparison.
So basically you're checking if the file whose filename is stored in $i
is newer than the file with filename ${LOG_DIR_PATH}/test
.
精彩评论