1

我想在 HDFS 上打印文件名及其修改日期,hdfs 的问题是它不支持 ls -l 命令,所以当我 hdfs dfs -ls /directory_path 在这里使用时是示例输出

Found 6 items
drwxr-xr-x - dps12 supergroup 0 2013-08-14 05:10 /data/PSG/LZ/FORECAST/201
drwxr-xr-x - dps12 supergroup 0 2013-08-15 05:13 /data/PSG/LZ/FORECAST/201
drwxr-xr-x - dps12 supergroup 0 2013-08-16 05:15 /data/PSG/LZ/FORECAST/203
drwxr-xr-x - dps12 supergroup 0 2013-07-30 20:32 /data/PSG/LZ/FORECAST/204
drwxr-xr-x - dps12 supergroup 0 2013-07-31 22:54 /data/PSG/LZ/FORECAST/205
drwxr-xr-x - dps12 supergroup 0 2013-08-13 04:15 /data/PSG/LZ/FORECAST/206

我需要的输出是

2013-08-14 /data/PSG/LZ/FORECAST/201
2013-08-15 /data/PSG/LZ/FORECAST/201
2013-08-16 /data/PSG/LZ/FORECAST/203
2013-07-30 /data/PSG/LZ/FORECAST/204
2013-07-31 /data/PSG/LZ/FORECAST/205
2013-08-13 /data/PSG/LZ/FORECAST/206

我知道对于专家来说,这一定很容易,任何帮助或指示我如何实现这一点都会有很大帮助..

我曾想过使用

hdfs dfs -ls /directory_path | while read line ; do $line|awk 'print $4  $6' ; done;

但这没有任何帮助

4

1 回答 1

4

请尝试使用 awk -

hdfs dfs -ls /directory_path | grep -v 'Found' | awk '{ print $6,$8 }'

grep -v 'Found'用于忽略Found x items开头的行。

感谢 psny。

于 2013-08-15T11:21:22.593 回答