the program too slow there is any solution?

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users the program too slow there is any solution?
# 1  
Old 10-01-2007
the program too slow there is any solution?

i want to make match between two file:
the first about 1000 records
and the second about 67000 records
I used the nested loop for that the program is two slow
how can i fast this the program

more file1|while read i
more file2|while read x
if $parameter1=$parameter2
then .....
# 2  
Old 10-01-2007
(a) sort the files first, change your algorithm

(b) write the program in C or Perl

shell scripts are *really* bad languages for intensive processing.
# 3  
Old 10-01-2007
the sort is impossible
and my knowledge of c and perl is weak

con you show me an exable in c
# 4  
Old 10-01-2007
FILE *fp1=fopen("file1.txt","r");
FILE *fp2=fopen("file2.txt","r");
char buf1[256];
char buf2[256];

while (fgets(buf1,sizeof(buf1),fp1))

     while (fgets(buf2,sizeof(buf2),fp2))

# 5  
Old 10-01-2007
thanks porter
# 6  
Old 10-01-2007
There is no such thing as unsortable data. If you can compare the keys, you can sort them. But I would read the 1000 record file into an array. Then read the 2nd file and compare to the elements of the array.
# 7  
Old 10-01-2007
awk is designed to do this using what are called associative arrays.
If you post sample data, say 5 from the small file and 20 from the big, we can give you an example.
Login or Register to Ask a Question

Previous Thread | Next Thread

3 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

2. Shell Programming and Scripting

Please can you help me find a solution in this program in unix ?

Write shell script to read 3 numbers and print them in revers and print wither they are polyndrome numbers or not ????? (2 Replies)
Discussion started by: lovelorn_mn
2 Replies

3. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies
Login or Register to Ask a Question