Could you please let me know if you want to show only current date files?
as by seeing your Output, it seems the same. Please confirm so that I can try to help you.
I want to show the file having latest timestamp for each file (Not the current date fiels )
Means for file1 it is having 2 timestamps with ( 20130601 ,20130615 )
and I need the latest timestamp file as output .
typeset -A arr
for file in YDT:FILE*
do
pfx="${file%:*}"
sfx="${file##*:}"
[ -z ${arr[$pfx]} ] && arr[$pfx]=$sfx
[ ${arr[$pfx]} -lt $sfx ] && arr[$pfx]=$sfx
done
for k in ${!arr[@]}
do
echo "$k:${arr[$k]}"
done
could you please try this, may be it will be helpful for you.
$ cat timings_file_query.ksh
echo "Please enter the number of files present types for files like file1, file2....till which file"
echo "eg--> lets say we have file1 to file30 so please enter 30 in the case"
read number_of_files
a=1
while [ ${a} -le ${number_of_files} ]
do
name=`echo "YDT:FILE"$a`
value_for_files_present_in_path=`ls -ltr | grep -v "grep" | grep $name | awk '{print$9}' | tail -1`
echo $value_for_files_present_in_path
let "a = a + 1"
done
Output is as follows:
$ ksh timings_file_query.ksh
Please enter the number of files present types for files like file1, file2....till which file
eg--> lets say we have file1 to file30 so please enter 30 in the case
2
YDT:FILE1:20130615
YDT:FILE2:20130622
$