获取 HDFS 中最后更新的文件 [英] Get the last updated file in HDFS

查看:32
本文介绍了获取 HDFS 中最后更新的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要来自我的 HDFS 目录之一的最新更新文件.代码应该基本上遍历目录和子目录,并获取带有文件名的最新文件路径.我能够在本地文件系统中获取最新文件,但不确定如何为 HDFS 执行此操作.

I want the latest updated file from one of my HDFS directories. The code should basically loop through the directories and sub directories and the get the latest file path with the file name.I was able to get the latest file in local file system but not sure how to do it for HDFS one.

find/tmp/sdsa -type f -print0 |xargs -0 stat --format '%Y :%y %n' |排序-nr |剪切 -d: -f2- |头部

以上代码适用于本地文件系统.我可以从 HDFS 获取日期、时间和文件名,但是如何使用这 3 个参数获取最新文件?

The above code is working for local file system. I am able to get the date , time and file name from HDFS, but how do I get the latest file using these 3 parameters?

这是我试过的代码:

hadoop fs -ls -R/tmp/apps |awk -F" " '{打印 $6" "$7" "$8}'

任何帮助将不胜感激.

提前致谢.

推荐答案

这个对我有用:

hadoop fs -ls -R/tmp/app |awk -F" " '{打印 $6" "$7" "$8}' |排序-nr |头-1 |cut -d" " -f3

输出是整个文件路径.

这篇关于获取 HDFS 中最后更新的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆