I did make a post about my script to generate numbers combination depends on user input to set the number of digits a few weeks ago. And I was thinking to make it more clean and user friendly after received a comments from "Pak Leman".
So here is the update of the scripts. The script will asked user to input the digits of combination to generate. And will asked user to give the output filename. So no more "sh script 8 > huhu.txt" . To run the script just run "sh script" and it will ask you all the details using script.
So here is the full codes of the script, and also pictures of the output:
echo "Please give the digits for combinations[8-63]: \c"
echo "Please type the output file name: \c"
FINISH=`expr "10^"$digit"" | bc -l`
if [ $digit -lt 8 -o $digit -gt 64 ]
echo "The digit you specify is ' $digit '. "
echo "Please enter a valid digit [8-63]: \c"
while [ $COUNT != `expr $FINISH - 1` ] ; do
COUNT=`expr $COUNT + 1`
printf "%+"$digit"s\n" $COUNT | sed s^\ ^0^g >> $OUTFILE
So any opinion on how to improve the script are most welcome. Somehow the script still allow digits more than 63. Still looking forward to repair this script. Any thought or advise are welcome. Please drop some comments.