/media/bill/SAMSUNG_G4/IJCNN2019/System_maintenance/Linux/zero_pad numbers.txt www.BillHowwell.ca 29Jul2019 initial ************** 29Jul2019 see "/media/bill/SWAPPER/bin/SSH/sftp logon lists & stats.sh" #https://stackoverflow.com/questions/8789729/how-to-zero-pad-a-sequence-of-integers-in-bash-so-that-all-have-the-same-width#8789815 #More generally, bash has printf as a built-in so you can pad output with zeroes as follows: #$ i=99 #$ printf "%05d\n" $i #00099 # #You can use the -v flag to store the output in another variable: #$ i=99 #$ printf -v j "%05d" $i #$ echo $j #00099 # #edited Jan 9 '12 at 14:26 #answered Jan 9 '12 at 14:17 #Dave Webb doesn't work as above : just assign intermediate variable : rm "$p_hackNIP_temp" while read -u 9 z_hackers_IPad; do counter1=$( grep -c "$z_hackers_IPad" "$p_hackAcc_temp" ) counter=$( printf "%05g" $counter1 ) echo "$counter"\\t"$z_hackers_IPad" >>"$p_hackNIP_temp" done 9<"$p_hackIPs_temp" sort -u --reverse "$p_hackNIP_temp" >"$p_hackers_hist" # enddoc