Below is the output now i need to filter based on latest modified timestamp.
I know 3 is the latest modified time stamp but i tried different options but only filtering docs and not on headnote..Can any one tell me how to do that..
#!/bin/ksh
BaseDir='/app/data'
BaseDir="$PWD"
newest=''
find "$BaseDir" -name 'Availability' |
while read -r path
do if [ "$newest" = '' ] || [ "$path" -nt "$newest" ]
then newest="$path"
fi
done
printf 'The most recent file is "%s".\n' "$newest"
but it uses a couple of non-standard features. The test -nt operator is a non-standard extension provided by many shells including bash and ksh . And, according to the standards, commands executed in a multi-command pipeline may either be executed in a subshell execution environment or in the current shell execution environment. The Korn shell runs the last command in a pipeline in the current shell execution environment; so the script above works. To run this script with bash the printf command at the end of the script would have to be put in a subshell with the while loop:
#!/bin/bash
BaseDir='/app/data'
BaseDir="$PWD"
newest=''
find "$BaseDir" -name 'Availability' | (
while read -r path
do if [ "$newest" = '' ] || [ "$path" -nt "$newest" ]
then newest="$path"
fi
done
printf 'The most recent file is "%s".\n' "$newest"
)