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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to create a file contains millions of lines and each line has different datas?
# 1  
Old 05-31-2016
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:
Code:
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.
# 2  
Old 05-31-2016
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?
# 3  
Old 05-31-2016
Quote:
Originally Posted by RudiC
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 timeSmilie
# 4  
Old 05-31-2016
Is that a homework question? Those should be posted in Homework & Coursework Questions using the correct form according to the forum rules.
# 5  
Old 05-31-2016
Quote:
Originally Posted by RudiC
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
# 6  
Old 05-31-2016
Code:
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).

Last edited by stomp; 05-31-2016 at 04:45 PM..
This User Gave Thanks to stomp For This Post:
# 7  
Old 05-31-2016
novice try

For your reference, here is what I tried:
Code:
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 speakingsounds 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.

Last edited by yifangt; 05-31-2016 at 06:18 PM.. Reason: update answer
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find all lines in file such that each word on that line appears in at least n lines of the file

I have a file where every line includes four expressions with a caret in the middle (plus some other "words" or fields, always separated by spaces). I would like to extract from this file, all those lines such that each of the four expressions containing a caret appears in at least four different... (9 Replies)
Discussion started by: uncleMonty
9 Replies

2. Shell Programming and Scripting

Read Lines from One file.. and create another.. and

Hello Members, I have one file which contains million of supplier code. I need to load these codes into database 1000 at a time. Database procedure reads from an external table which is based on the unix files. All I want to do is to read from the bigger file e.g. MAIN_FILE.txt and create... (1 Reply)
Discussion started by: chetanojha
1 Replies

3. Shell Programming and Scripting

How to compare 2 files and create a result file with unmatched lines from first file.?

HI, I have 2 text files. file1 and file2. file1.txt (There are no duplicates in this file) 1234 3232 4343 3435 6564 6767 1213 file2.txt 1234,wq,wewe,qwqw 1234,as,dfdf,dfdf 4343,asas,sdds,dsds 6767,asas,fdfd,fdffd I need to search each number in file1.txt in file2.txt's 1st... (6 Replies)
Discussion started by: Little
6 Replies

4. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

5. Shell Programming and Scripting

Ignoring lines and create new file

Hello, I have a requirement to ignore few lines in a file before keyword FILEHEADER . As soon as there is keyword FILEHEADER is identified in file , it will form another file with data from FILEHEADER to whatever in file after FILEHEADER. I wrote filename=$1 awk... (4 Replies)
Discussion started by: callmatkarna
4 Replies

6. Shell Programming and Scripting

Need an efficient way to search for a tag in an xml file having millions of rows

Hi, I have an XML file with around 1 billion rows in it and i am trying to find the number of times a particular tag occurs in it. The solution i am using works but takes a lot of time (~1 hr) .Please help me with an efficient way to do this. Lets say the input file is <Root> ... (13 Replies)
Discussion started by: Sheel
13 Replies

7. UNIX for Dummies Questions & Answers

Comparing datas in two excel file

Hi All, i have two excel sheets with same column name as below col1 col2 col3 ---- ---- ----- 1 121 156 24 456 788 45 444 777 765 32 77 col1 col2 col3 ---- ---- ----- 24 456 ... (1 Reply)
Discussion started by: arunmanas
1 Replies

8. Shell Programming and Scripting

arranging datas if input file is not having also...!!

hi, my input file is containg uid, eriMaster ,eriResign, ericontry, dept. some of the uid are not having all info. out put should include all info irrespctive of datas of input file if any one data is missing, then it has to print Null or zero..then continue with the existing one. here... (0 Replies)
Discussion started by: hegdeshashi
0 Replies

9. Shell Programming and Scripting

read line by line and create new file

I would like to read line by line out of a file (one word per line) and create with each line a file. The read line should be also pasted into the file with some other text. Something like this: cat readfile.txt | mkfile readline << "bla bli $readline blu" (7 Replies)
Discussion started by: borobudur
7 Replies

10. Shell Programming and Scripting

select datas from an input file

I have a file containing a list of references and I want to run a script that will make the same action for each reference. The input file changes every hour, it's why I want to use a script that can read in a file, record by record, and run a specific action for the reference readed. Thanks... (1 Reply)
Discussion started by: dde
1 Replies
Login or Register to Ask a Question