sort a file which has 3.7 million records


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sort a file which has 3.7 million records
# 1  
Old 07-14-2009
sort a file which has 3.7 million records

hi,
I'm trying to sort a file which has 3.7 million records an gettign the following error...any help is appreciated...

sort: Write error while merging.

Thanks
# 2  
Old 07-14-2009
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
# 3  
Old 07-14-2009
Howdy!

The most probable reason might be that your disk got full or that your disk quota was exceeded. If you have another mounted partition/disk with more space, try

Code:
sort -T /path/to/where/you/have/more/space

Hope it helped,

Matt
# 4  
Old 07-14-2009
Please state which Operating System, the command you typed, the exact size of the file, and the amount of free disc space in each disc partition involved (source file, destination file, sort work files). In most versions of sort the default location of sort work files is /tmp .
# 5  
Old 07-14-2009
How about breaking the file into multiple small files do the sort and merge them later.
As pointed out the disk is full, check with "du" in UNIX/Linux.
Try Perl/Python to do a intelligent sort, bubble or something (Please note: At this time I am not thinking of the big 'O' or what is efficient. Just giving few ideas.
# 6  
Old 07-14-2009
Ex. split using awk. In this example has used two first letters/line to split file.

Code:
#!/bin/ksh
rm -f *.split 2>/dev/null
awk  -v keylen=2 '{
        key=substr($0,1,keylen)
        print $0 >> key".split"
        }' bigfile

> newbig
for f in ??.split
do
   sort "$f" >> newbig
done

# 7  
Old 07-15-2009
Sort

You may want to check the disk space where your /tmp is ?

Thanks
Ashok
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read records in a file and sort it?

I have a file which has number of pipe delimited records. I am able to read the records....but I want to sort it after reading. i=0 while IFS="|" read -r usrId dataOwn expire email group secProf startDt endDt smhRole RoleCat DataProf SysRole MesgRole SearchProf do print $usrId $dataOwn... (4 Replies)
Discussion started by: harish468
4 Replies

2. Shell Programming and Scripting

Matching 10 Million file records with 10 Million in other file

Dear All, I have two files both containing 10 Million records each separated by comma(csv fmt). One file is input.txt other is status.txt. Input.txt-> contains fields with one unique id field (primary key we can say) Status.txt -> contains two fields only:1. unique id and 2. status ... (8 Replies)
Discussion started by: vguleria
8 Replies

3. UNIX for Dummies Questions & Answers

Alphabetical sort for multi line records contains in a single file

Hi all, I So, I've got a monster text document comprising a list of various company names and associated info just in a long list one after another. I need to sort them alphabetically by name... The text document looks like this: Company Name: the_first_company's_name_here Address:... (2 Replies)
Discussion started by: quee1763
2 Replies

4. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

5. Shell Programming and Scripting

Unix sort for fixed length columns and records

I was trying to use the AIX 6.1 sort command to sort fixed-length data records, sorting by specific columns only. It took some time to figure out how to get it to work, so I wanted to share the solution. The sort man page wasn't much help, because it talks about field delimeters (default space... (1 Reply)
Discussion started by: CheeseHead1
1 Replies

6. Shell Programming and Scripting

Extract data from large file 80+ million records

Hello, I have got one file with more than 120+ million records(35 GB in size). I have to extract some relevant data from file based on some parameter and generate other output file. What will be the besat and fastest way to extract the ne file. sample file format :--... (2 Replies)
Discussion started by: learner16s
2 Replies

7. Shell Programming and Scripting

Sort & Split records in a file

Hi, I am new to scripting. I need a script to sort and the records in a file and then split them into different files. For example, the file is: H1...................... H2...................... D2.................... D2.................... H1........................... (15 Replies)
Discussion started by: Sunitha_edi82
15 Replies

8. Shell Programming and Scripting

How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort. Suppose if the records like below: 345,bcd,789 123,abc,456 234,abc,456 712,bcd,789 out tput should be 345,bcd,789 123,abc,456 Key for the records is 2nd and 3rd fields.fields are seperated by colon(,). (19 Replies)
Discussion started by: svenkatareddy
19 Replies

9. Solaris

How to remove duplicate records with out sort

Can any one give me command How to delete duplicate records with out sort. Suppose if the records like below: 345,bcd,789 123,abc,456 234,abc,456 712,bcd,789 out tput should be 345,bcd,789 123,abc,456 Key for the records is 2nd and 3rd fields.fields are seperated by colon(,). (2 Replies)
Discussion started by: svenkatareddy
2 Replies

10. UNIX for Dummies Questions & Answers

How to Sort Records Uniquely?

I have a file containing many records separated by a % that I would like to sort uniquely (and if possible with a count of dupes) while maintaining the integrity of each record. File looks like this: % srcip: 5.6.7.8 srcburb: internal dstip: 1.2.3.4 dstport: 2000 dstburb: external... (12 Replies)
Discussion started by: earnstaf
12 Replies
Login or Register to Ask a Question