在linux输出进度条效果

PHP版

	$total = 100;
    for ($i = 1; $i <= $total; $i++) {
        printf("progress: [%-50s] %d%% \r",
          str_repeat('#',$i/$total*50), 
          $i/$total*100);
        usleep(50000);
    }

Bash版

b='' 
for ((i=0;$i<=100;i+=2)) 
do 
	printf "progress: [%-50s] %d%%\r" $b $i 
	sleep 0.1 
	b+='#' 
done 
echo

你可能感兴趣的:(PHP,Linux学习,shell,php,linux)