linux - bash scripting language print a list of numbers using a loop -
i want print in text file (numberlist.txt), using bash, numbers 000000 999999, 1 number in each line. example:
000000 000001 000002 ... 999999
this code: (when run nothing happens)
#!/bin/bash cont=0 max_num=1000000 file_name=numberlist.txt #while counter cont lower max_num (-lt, “lower #than”) loop executed until [ $cont -lt $max_num ]; printf "%000002d\n" $cont > $file_name #cont= cont + 1 let cont+=1 done
what doing wrong?
instead of opening , closing file million times, once redirecting output of the loop instead of printf:
#!/bin/bash cont=0 max_num=1000000 file_name=numberlist.txt while [ $cont -lt $max_num ]; printf "%06d\n" $cont #cont= cont + 1 let cont++ done > $file_name
Comments
Post a Comment