Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging 2 Files

Status
Not open for further replies.

dayankoven

Programmer
Oct 28, 2002
17
MY
Hi everyone,

I have a situation in which i need to merge 2 files, File A and File B. Both files are fixed length files and the file format is identical. The only problem is that the files are really very very huge. Each file is has about 2 million records. Each line is about 528 bytes. So, i'm looking at about 10560 MB of data per file.

I believe we can invoke a CAT command

CAT File A File B > File C.

I've read somewhere that the CAT command doesn't work well for huge files.

Is there a way i can achieve this merging in a very fast and efficient way via UNIX scripting.

Thanks in advance for all the help.

 
while read oneLine
do
echo $oneLine >> file_C
done < file_A

while read oneLine
do
echo $oneLine >> file_C
done < file_B

The above lines in a script should do the job for you.
 
rkrishnan, the goal is efficient way, so doing a shell read line by line is certainly not an option.
dayankoven, you may consider something like this:
cp "File A" "File C"
cat "File B" >> "File C"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top