jjennifer
jjennifer

Reputation: 1315

Paginate a big text file

I have a big text file. Each line in the file is a record. And I need to parse the text file and show only 20 records in a HTML table at a time. I will have to support sorting as well.

What I am currently doing is read the file line by line based on the parameters start, stop, and page_size which is provided in querystring. It seems to work fine until I have to sort the records, because in order to sort I need to process every line in the text file.

So is there a Unix command which can I extract from line to line and sort? I tried grep but I do not know enough it to get this problem solved.

Upvotes: 1

Views: 909

Answers (2)

David W.
David W.

Reputation: 107070

Take a look at the pr command. This is what we use to use all the time to paginate big files. You can set the page length, headers, footers, turn on line numbers, etc.

There's probably even a way to munge the output into HTML.

Upvotes: 4

reo katoa
reo katoa

Reputation: 5801

How big is the file?

man sort

Here

Upvotes: 0

Related Questions