gpt4 book ai didi

hadoop - 使用通配符检查文件是否存在于 hdfs 中

转载 作者:可可西里 更新时间:2023-11-01 15:30:03 29 4
gpt4 key购买 nike

我想检查一个文件是否存在于 hdfs 中。我正在使用

if $(hadoop fs -test -e $myfilewithpath) ; then echo "ok";else echo "not ok"; fi

现在我收到类似

的错误消息

test: `/data/bi/udm/incoming/Viewership/year=2016/month=02/day=26/hour=07/part-m-*.avro': No such file or directory
not ok

我在路径中期望的文件可以是任何映射器输出文件,即它可以是 part-m-00000.avro 或者它可以是 part-m-00099.avro 这就是我在搜索中使用 * 的原因,例如 part-m-*.avro

但是我们可以消除下面的消息并只得到输出 not ok

test: `/data/bi/udm/incoming/Viewership/year=2016/month=02/day=26/hour=07/part-m-*.avro': No such file or directory

最佳答案

我可以通过下面的代码解决它

if $(hadoop fs -ls $tilldirectorypath|grep "part-m-*.avro") ; then echo "ok";else echo "not ok"; fi

Where tilldirectorypath=/data/bi/udm/incoming/Viewership/year=2016/month=02/day=26/hour=07

And previous path defined as myfilewithpath=/data/bi/udm/incoming/Viewership/year=2016/month=02/day=26/hour=07/part-m-*.avro

关于hadoop - 使用通配符检查文件是否存在于 hdfs 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35659371/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com