注意:shell中的字符串拼接是不须要用+号的,直接在字符串后面继续添加便可。如:${file}-`date +%s`.ok,最后出来的就是file名字+日期+.oklinux
1.批量去除.ok后缀的文件名,使用表达式${string%substring}shell
for file in `hdfs dfs -find $1 -name "*.ok"` |
2.测试文件夹的大小,result包含几个值,用空格分开,只有第一个是文件夹的大小。首先将空格用AAA代替,表达式:${result// /AAA}。而后取出第一个AAA的index,表达式:expr index ${result_rep} AAA。最后再截取字符串,表达式:expr substr ${result_rep} 1 ${index}spa
result=`hdfs dfs -du -s /user/hive/warehouse/splited_tmp_split` |