Sorting binary files using UNIX sort


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Sorting binary files using UNIX sort
# 1  
Old 02-16-2012
Sorting binary files using UNIX sort

Hi,

Can i sort binary files using unix sort ?
# 2  
Old 02-16-2012
unix sort will only files with carriage control, so-called ascii 'text' files. if your file is truly binary (data is from variables written directly from memory with no formatting) then you will have to use a programming language.

When you edit the file is it human readable?
# 3  
Old 02-25-2012
Hi Jim,

The file which i am trying to sort is a fixed length binary file. Its been created using a structure using C++ programming language.


Regards,
Ambika

---------- Post updated at 09:37 AM ---------- Previous update was at 09:25 AM ----------

Jim,

Also is there any limit on the size of file when we are sorting using UNIX sort. I have observed that sorting a huge file takes lot of time which may not be expected in actual implementation.
# 4  
Old 02-25-2012
If the file can be read randomly (relative record number) then add a file to your C++ program to create a text file containing the record number and the sort key. Sort this file, and then use it as an index to the binary file.
The length of time a sort takes is generally proportionate to the square root of the number of records.
# 5  
Old 02-25-2012
Code:
sorting a huge file takes lot of time

How big is "huge"?
How long is "lot of time"?
What command did you type?
How much free memory do you have?
What Operating System and version do you have and what Shell do you use?

The performance of a unix "sort" can be improved by giving it more memory. Depends on your system.
As others advise a unix "sort" is only suitable for ASCII Text Files with proper unix record terminators.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to sort the files by size and based subdirectory un UNIX?

I have the below input data in a file and need to get the output as mentioned below. Need to sort the data by size(Asc/des)/by subdirectory Below is the input which is there in a file: 120 /root/path2/part-00000-d3700305-428d-4b13-8161-42051f4ac5ed-c000.json 532 ... (3 Replies)
Discussion started by: ajarramuk
3 Replies

2. OS X (Apple)

Sorting scientific numbers with sort

Hey everybody, I'm trying to sort scientific numbers in a descending order using the command sort -gr <file>. It works fine on a Linux-Server, but doesn't on my macbook pro with OS X 10.10.3 (Yosemite). I tried to sort the following: 6.38e-10 6.38e-10 1.80e-11 1.00e-10 1.48e-12 And... (9 Replies)
Discussion started by: plebs
9 Replies

3. Shell Programming and Scripting

Sorting data - awk or sort or both

data: C812F5C9B 0818053014 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED C812F5C9B 0818054514 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED C812F5C9B 0818060014 P S SYSPROC SOFTWARE PROGRAM ABNORMALLY TERMINATED C812F5C9B 0818061514 P S SYSPROC ... (3 Replies)
Discussion started by: SkySmart
3 Replies

4. UNIX for Dummies Questions & Answers

Sorting files ending in numbers with "sort"

I have a group of files that I need to be sorted by number. I have tried to use the sort command without any luck. ls includes* includes1 includes10 includes11 includes12 includes2 includes3 includes4 includes5 includes6 includes7 includes8 includes9 I have tried ls includes*... (6 Replies)
Discussion started by: newbie2010
6 Replies

5. Shell Programming and Scripting

sorting files in unix

Hi , I have following error files in /srv/trillium/Projects/SAS_AML/logs dir. srtforpm_p3.err tranfrmr_p1.err tranfrmr_p9.err winkey_p5.err tranfrmr_p10.err srtforrl_p15.err tranfrmr_p6.err srtforrl_p7.err tranfrmr_p8.err tranfrmr_p14.err tranfrmr_p13.err tranfrmr_p12.err... (3 Replies)
Discussion started by: sonu_pal
3 Replies

6. Shell Programming and Scripting

Sorting Date Field with Sort -k :/

SOLVED : (17 Replies)
Discussion started by: Glitch100
17 Replies

7. UNIX for Dummies Questions & Answers

sorting numbers with sort -n

Looking for help for sort, I learned that for sorting numbers I use: sort -n but it seems that that is not enough when you have numbers like 0.2000E+7 for example, sort -n will not worry about the E+7 part, and will just sort the numbers like 0.2000. Exapmle: cat example.txt .91000E+07... (9 Replies)
Discussion started by: cosmologist
9 Replies

8. Programming

C: Binary Insertion Sort Optimization: Scoreboard

Hello, As part of a scheme to determine the top 10 5x5 Boggle board configurations beyond a reasonable doubt, I set out to optimize every aspect of the problem, and this is part one of a series of web pages that I am going to publish shortly... Optimal Binary Insertion Sort - Scoreboard Is... (0 Replies)
Discussion started by: HeavyJ
0 Replies

9. Shell Programming and Scripting

Editing Binary Files in Unix

Hi, Is there a way to edit BINARY files in Unix. Or even are there any commands (shellscript/perl) through which I can replace all the occurences of a string inside a BINARY file with another string ?? (1 Reply)
Discussion started by: cool.aquarian
1 Replies

10. UNIX for Advanced & Expert Users

help with sorting sequence in Unix C:sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list

Hi List is 000|2008-07-17|556543|RTJ|35-RTGJ|EYT 465|2008-11-10|567789|GHJ|45-DGHH|ETU 533|2008-09-06|567789|GHJ|45-DGHH|ETU How does it do it? sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list (6 Replies)
Discussion started by: gurvinder
6 Replies
Login or Register to Ask a Question