To get latest hdfs file system

Hi All,

I am having below hdfs file system

/user/home/dte=2019_01_30/part_1
/user/home/dte=2019_01_30/part_2
/user/home/dte=2019_01_31/part_1

I need to take the latest month hdfs folder while passing date as parameter.
For eg . if i pass as Feb month i.e. 20190201(YYYYMMDD), then i need the output as 2019_01_31 by reading the above hdfs direcotories. I also need to check if there are any data then get the dte as 2019_01_31. For eg /user/home/dte=2019_01_31/part_1 should be more than 0 KB file

My try where i am struck

final_cnt =`hadoop fs -cat /user/home/dte=2019_01_31/part_1 | wc -l`
if [ $final_cnt >1 ]
then
finat_dte = `hdfs dfs -ls -R /user/home/dte=2019_01_31/ | grep  "^-" | tr -s " " | cut -d' ' -f6-8 | `