re: Write a simple but impactful script VIEW POST



for i in {0..9999}; do printf "%04d\n" $i; done | sort -R > pins.txt


Using shuf utility for shuffling:

for i in {0..9999}; do printf "%.4d\n" $i; done | shuf > pins.txt

The two scripts are equivalent as the man sort page tells that -R option uses shuf.


I don't have sort -R or shuf (I'm on OS X). I did not know you could do the dot precision thing with integers! My solution was basically the same, but I did "%04d\n"

code of conduct - report abuse