shell 读取文件行
来源:互联网 发布:vps加速软件 编辑:程序博客网 时间:2024/04/29 20:00
有道笔记-shell 读取文件行
最近通过Spark Streaming消费Kafka数据,消费的数据落到hdfs,一分钟一个小文件,昨天架构那边的同事告诉我要清理历史文件,但是目录太多,手动删比较慢,于是想到可以把文件目录都拿到,写入文本 path_to_clean.txt,通过shell循环读路径,并执行删除。
hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-01-09hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-07-05hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-09-05hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-10-20hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-11-06hdfs://nameservice1/user/hadoop/dw_realtime/dw_real_for_path_list/mb_pageinfo_hash2/date=2016-11-07...
已下是代码。
方式一(我才采用的是这种)
#!/bin/bashfor line in `cat path_to_clean.txt`do echo $line hadoop fs -rm -r $linedone
方式二
#!/bin/bashwhile read linedo echo $linedone < path_to_clean.txt
方式三
#!/bin/bashcat path_to_clean.txt | while read linedo echo $linedone
0 0
- shell 读取文件行
- shell按行读取文件
- shell读取文件 随机读取
- shell读取文件的指定行字符串
- shell读取文件的行与列
- shell脚本-----按行读取文件
- shell脚本-----按行读取文件
- shell按行读取文件的方法
- Shell按行读取文件的方法
- linux shell 逐行读取文件行
- shell脚本-----按行读取文件-转
- shell读取文件的指定行字符串
- shell脚本 - sed文件读取指定行
- shell 按行读取文件的问题
- shell读取文件固定的几行
- linux shell 按行读取文件
- Shell读取文件内容
- shell逐行读取文件
- myeclipse导出war包,并把war部署tomcat上运行
- NumPy中的乘法运算符 * 指示按元素计算,矩阵乘法可以使用 dot 函数或创建矩阵对象实现
- BZOJ2669: [cqoi2012]局部极小值
- Leetcode——228. Summary Ranges
- maven 使用本地jar
- shell 读取文件行
- sizeof(struct)与sizeof(union)
- angularjs input
- 二、模块详解3
- Linux 下换行符转换
- View事件分发和坐标系统总结
- C#用WebClient下载File时操作超时的问题
- 基于Linux的聊天室(客户端)初成版
- centos添加win10引导