Linux 删除hdfs上的指定文件夹

    xiaoxiao2022-07-04  98

    @羲凡——只为了更好的活着

    Linux 删除hdfs上的指定文件夹

    知识点1:用 cat … | while read line 循环文件的每一行 知识点2:用 =~ 判断左边字符串是否包含右边字符串

    batchid=20190520202202 hdfs dfs -ls /Data/beforeMerge/$batchid/JON* | awk '{print $8}' > file.txt cat ./file.txt | while read line do if [[ $line =~ "ID010205" ]] then echo $line;hdfs dfs -rm -r $line fi done rm -rf file.txt

    结果展示

    /Data/beforeMerge/20190520202202/JON20171211000000186/ID010205 /Data/beforeMerge/20190520202202/JON20171211000000191/ID010205 /Data/beforeMerge/20190520202202/JON20171215000000212/ID010205 /Data/beforeMerge/20190520202202/JON20171215000000216/ID010205

    有关linux判断包含字符串:https://www.cnblogs.com/AndyStudy/p/6064834.html

    ====================================================================

    @羲凡——只为了更好的活着

    若对博客中有任何问题,欢迎留言交流

    最新回复(0)