I need the latest updated file from one of my HDFS directories. The code should basically scroll through directories and auxiliary directories and get the last path to the file with the file name. I was able to get the latest file on the local file system, but not sure how to do it for HDFS.
find /tmp/sdsa -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head
The above code works for the local file system. I can get the date, time and file name from HDFS, but how to get the last file using these 3 options?
this is the code i tried:
hadoop fs -ls -R /tmp/apps | awk -F" " '{print $6" "$7" "$8}'
Any help would be appreciated.
Thanks in advance.
source share