I have never used hadoop; if you want to download total logs, you can try:
cnt=0
total=100
for file in $(ls /test/*.log); do
echo hadoop fs -get ${file}
let cnt=$((${cnt} + 1)) # 这个 bash 可以用,别的 Shell 你改一下吧
if [ ${cnt} -ge ${total} ]; then
break
fi
done
You can remove the echo yourself. I wrote the command directly by hand. I have not tried it. Generally speaking, in production, test the echo first to see if the output is correct. If there is no problem, then execute it.
After reading the tips below, I will add a simple one:
ls /test/*.log | head -100 | xargs echo hadoop fs -get
I have never used hadoop; if you want to download total logs, you can try:
You can remove the echo yourself. I wrote the command directly by hand. I have not tried it.
Generally speaking, in production, test the echo first to see if the output is correct. If there is no problem, then execute it.
After reading the tips below, I will add a simple one:
You can try it.
There is a head command in shell, but I don’t know if it is available in hadoop