awk
倒数第二位
name=`echo $line | awk -F'/' '{print $(NF-1)}'`
最后一位
name=`echo $line | awk -F'/' '{print $NF}'`
第一位
name=`echo $line | awk -F'/' '{print $1}'`
hdfs dfs -ls ${hdfs_calc_out_path}/ | awk '{print $8}' > files.txt
cat ./files.txt | while read line
do
result=$(echo $line | grep ${hdfs_calc_out_path} )
if [[ "$result" != "" ]];then
result=$(echo $file_flag | grep "true")
if [[ "$result" != "" ]];then
hdfs dfs -text $line/* >> ${out_id_type}
else
name=`echo $line | awk -F'/' '{print $(NF-1)}'`
fi
fi
done