Score:-1

How can I generate a number start with 1 and only has 10 digit bash script

ng flag

How can I generate all the numbers that start with 1 and have 10 digits?

For example: start with: 1000000000 ... end with: 1999999999

And how to save the result in a text file?

Artur Meinild avatar
vn flag
Does this answer your question? [How to get a random number within a range in command line?](https://askubuntu.com/questions/1213233/how-to-get-a-random-number-within-a-range-in-command-line)
Abdalaziz Alharthi avatar
ng flag
Hi Artur Meinild, no start with number 1 only and have 10 digits
Artur Meinild avatar
vn flag
... "start with number 1 only and have 10 digits" - sorry, this doesn't make sense to me.
Abdalaziz Alharthi avatar
ng flag
haha I mean for example : 1000000000 1100000000 ... 1111111111 , 1011111111 and end with 1999999999
Score:2
cn flag

Your question is unclear.

If you're looking to generate a random(-ish) number:

num=1
for i in {1..9}; do num+=$((RANDOM % 10)); done
echo "$num" > text.file

If you want the billion numbers from 1,000,000,000 to 1,999,999,999

for ((i = 1000000000; i <= 1999999999; i++)); do
    echo "$i"
done > text.file

As suggested by @bac0n

seq 1000000000 1999999999 > text.file
Abdalaziz Alharthi avatar
ng flag
This is exactly what I want many thanks.
cn flag
I'm still curious: _which_ did you want?
Abdalaziz Alharthi avatar
ng flag
I wanted all numbers between 1000000000 to 19999999999. :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.