注意: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` |