我想通过shell编写一个循环,并执行“ hadoop fs -cat”命令,但是完成后,它将显示“ cat:无法写入输出流”,因此它无法转到下一个循序渐进。我需要使用ctrl + c手动将其停止。那么如何停止Hadoop cat:在shell中运行循环时无法自动写入输出流?
和外壳在下面:
for i in {00..23}; do
echo "$i";
mkdir $i
cd $i
hadoop fs -cat hdfs://xxxx/20180816/$i/*.gz | zcat | head -60000 > tmp1
cd -
done
答案 0 :(得分:0)
for i in {1..2}
do
echo "$i"
mkdir $i
cd $i
hadoop fs -get /user/sandeep1/${i}.gz
gunzip -f ${i}.gz
rm ${i}.gz
hadoop fs -rm -r /user/sandeep1/${i}
hadoop fs -mkdir /user/sandeep1/${i}
hadoop fs -put * /user/sandeep1/${i}
hadoop fs -cat /user/sandeep1/${i}/* | head -n 1 > tmp1.txt
cd ..
done