Skip to main content
added 174 characters in body
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

First create a reference timestamp file with the correct mtime timestamp:

touch -d 2019-12-18T14:00 timestamp

Then parse your file and for each file test whether the file is newer than that timestamptimestamp file we just created:

while IFS= read -r name; do
    if [[ /prdusr/rhd/prdoper/opLogDir/$name -nt timestamp ]]; then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This uses the -nt file test in bash to check the modification timestamp (note that bash doesn't perform this test with a sub-second accuracy).

Using POSIX tools:

touch -d 2019-12-18T14:00 timestamp

while IFS= read -r name; do
    if [ -n "$( find "/prdusr/rhd/prdoper/opLogDir/$name" -newer timestamp )" ]
    then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This would do the test using find instead, which would output the found path if the file at hand was modified after the timestamp file, and the shell would detect the output as a non-empty string and call printf.

First create a reference timestamp file with the correct mtime timestamp:

touch -d 2019-12-18T14:00 timestamp

Then parse your file and for each file test whether the file is newer than that timestamp file we just created:

while IFS= read -r name; do
    if [[ /prdusr/rhd/prdoper/opLogDir/$name -nt timestamp ]]; then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This uses the -nt file test in bash to check the modification timestamp (note that bash doesn't perform this test with a sub-second accuracy).

Using POSIX tools:

touch -d 2019-12-18T14:00 timestamp

while IFS= read -r name; do
    if [ -n "$( find "/prdusr/rhd/prdoper/opLogDir/$name" -newer timestamp )" ]
    then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This would do the test using find instead.

First create a reference timestamp file with the correct mtime timestamp:

touch -d 2019-12-18T14:00 timestamp

Then parse your file and for each file test whether the file is newer than that timestamp file we just created:

while IFS= read -r name; do
    if [[ /prdusr/rhd/prdoper/opLogDir/$name -nt timestamp ]]; then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This uses the -nt file test in bash to check the modification timestamp (note that bash doesn't perform this test with a sub-second accuracy).

Using POSIX tools:

touch -d 2019-12-18T14:00 timestamp

while IFS= read -r name; do
    if [ -n "$( find "/prdusr/rhd/prdoper/opLogDir/$name" -newer timestamp )" ]
    then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This would do the test using find instead, which would output the found path if the file at hand was modified after the timestamp file, and the shell would detect the output as a non-empty string and call printf.

Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

First create a reference timestamp file with the correct mtime timestamp:

touch -d 2019-12-18T14:00 timestamp

Then parse your file and for each file test whether the file is newer than that timestamp file we just created:

while IFS= read -r name; do
    if [[ /prdusr/rhd/prdoper/opLogDir/$name -nt timestamp ]]; then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This uses the -nt file test in bash to check the modification timestamp (note that bash doesn't perform this test with a sub-second accuracy).

Using POSIX tools:

touch -d 2019-12-18T14:00 timestamp

while IFS= read -r name; do
    if [ -n "$( find "/prdusr/rhd/prdoper/opLogDir/$name" -newer timestamp )" ]
    then
        printf 'Updated: %s\n' "/prdusr/rhd/prdoper/opLogDir/$name"
    fi
done <new1.txt

This would do the test using find instead.