今天在写表的时候发现没有把历史数据删除,所以要删除非本日日期的文件。
1、首先将非本日日期的文件输出到txt
hdfs dfs -ls hdfs://warehouse/profile/ | grep -v 2022-03-09 >./2.txt
2、利用awk编写删除脚本
cat 2.txt | awk -F " " '{print "hadoop fs -rm -r " $8}' > ./1.sh
3、运行脚本
/bin/bash 1.sh
今天在写表的时候发现没有把历史数据删除,所以要删除非本日日期的文件。
1、首先将非本日日期的文件输出到txt
hdfs dfs -ls hdfs://warehouse/profile/ | grep -v 2022-03-09 >./2.txt
2、利用awk编写删除脚本
cat 2.txt | awk -F " " '{print "hadoop fs -rm -r " $8}' > ./1.sh
3、运行脚本
/bin/bash 1.sh