How to create a file contains millions of lines and each line has different datas?

I want to create a file contains millions of lines. The line format like this:

acnum$$123456$$+$$Tom$$111$$

fields separated by $$, field 1 and field 3 have only two options:acnum or crenum; + or -. field 4 can be any name or any letters. Other fields can be any fixed length digits. So, I want to create millions of lines and each line contains random data satisfied with the format.

Any attempts/ideas/thoughts from your side?

By merely counting up field 2 from 000000 to 999999 you can have 1 million different lines. Does that satisfy your needs or not, and why not?

I am a newbie, I have no clue. The best situation is some kind people get practised by helping me at the same time:D

Is that a homework question? Those should be posted in Homework & Coursework Questions using the correct form according to the forum rules.

what kind of question should be posted here? it's just a simple shell programming question. No help no speaking, thank you

acnum$$123456$$+$$Tom$$111$$

You may print 1 million of those fixed lines too, to get your result.

-------

The Choices:

  • One gets help who's at least trying.
  • One gets more help who tries very hard.
  • One gets the job completely done by another person - without any trying - if another person is paid money.

What's your style?

Shell-Scripting Tutorials are dangerously fast growing in numbers throughout the internet. You must be really fast to close your browser tab before you are accidentically forced to read such a site.

(Or in other words: Use Google, you find a million sites which help you understand Shell Scripting).

1 Like

For your reference, here is what I tried:

a=acnum; c=crenum; p="+"; m="-"
for i in `seq 1000000`; do 
num1=$[ 1 + $[ RANDOM % 1000000 ]]; 
num2=$[ 1 + $[ RANDOM % 1000000 ]]; 
i=$(expr $num1%2); j=$(expr $num1%2); 
str=$(gpw 1 15); #you need gpw installed
num1=$(printf %06d $num1); #pad the number uniformly to 6 digits
num2=$(printf %06d $num2); #pad the number uniformly to 6 digits
if [ $(( $i % 2 )) -eq 1 ]; then f1=$a; else f1=$c; fi; # Someone please improve this to ternary version that I could not figure out.
if [ $(( $j % 2 )) -eq 1 ]; then f3=$p; else f3=$m; fi; # same as above
echo $f1'$$'$num1'$$'$f3'$$'$str'$$'$num2'$$';
done

I believe this is a very novice version that can be improved for sure.

Also No help no speaking sounds not usual when you are seeking for help.
what kind of question should be posted here? ------Read the forum rules.
it's just a simple shell programming question. Sometimes the question can be challenging while it seems simple.

Thanks, stomp.

And, hhdzhu, if you don't answer the homework question, supplying plausible reason or evidence if its not homework, this thread may be closed.

close it, then. I can say any question is a homework if I want

Moderator comments were removed during original forum migration.
2 Likes