CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Fri, 18 Jul 2025 05:20:10 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080518204347
location: https://web.archive.org/web/20080518204347/https://examples.oreilly.com/upt2/split/chunksort
server-timing: captures_list;dur=0.655856, exclusion.robots;dur=0.027835, exclusion.robots.policy;dur=0.012813, esindex;dur=0.014639, cdx.remote;dur=235.216351, LoadShardBlock;dur=268.895410, PetaboxLoader3.datanode;dur=132.738734, PetaboxLoader3.resolve;dur=73.459717
x-app-server: wwwb-app210
x-ts: 302
x-tr: 532
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app210; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Fri, 18 Jul 2025 05:20:11 GMT
content-type: text/plain
content-length: 1944
x-archive-orig-date: Sun, 18 May 2008 20:43:45 GMT
x-archive-orig-server: Apache
x-archive-orig-last-modified: Mon, 31 Mar 2008 18:10:12 GMT
x-archive-orig-etag: "54c3aa-798-90194900"
x-archive-orig-accept-ranges: bytes
x-archive-orig-content-length: 1944
x-archive-orig-connection: close
cache-control: max-age=1800
x-archive-guessed-content-type: text/plain
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 18 May 2008 20:43:47 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 18 Jun 2002 23:23:32 GMT", ; rel="prev memento"; datetime="Thu, 20 Dec 2007 02:05:10 GMT", ; rel="memento"; datetime="Sun, 18 May 2008 20:43:47 GMT", ; rel="next memento"; datetime="Tue, 10 Feb 2009 08:33:22 GMT", ; rel="last memento"; datetime="Fri, 27 Sep 2019 04:45:42 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_3_20080518193113_crawl107-c/52_3_20080518204242_crawl100.arc.gz
server-timing: captures_list;dur=1.087500, exclusion.robots;dur=0.024267, exclusion.robots.policy;dur=0.011660, esindex;dur=0.010824, cdx.remote;dur=20.799650, LoadShardBlock;dur=926.086180, PetaboxLoader3.datanode;dur=162.830606, PetaboxLoader3.resolve;dur=908.608984, load_resource;dur=188.072113
x-app-server: wwwb-app210
x-ts: 200
x-tr: 1160
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
#! /bin/sh
#
### chunksort - sort multi-line records (separated by single blank lines)
### Usage: chunksort [-a] [sort options] [files]
##
## chunksort - SORT CHUNKS OF TEXT SEPARATED BY BLANK LINES, LIKE THIS:
##
## Using C on the UNIX System
## By Dave Curry
## 250 pages, ISBN 0-937175-23-4
##
## Checking C Programs with lint
## By Ian F. Darwin
## 84 pages, ISBN 0-937175-30-7
##
## THE -a OPTION MAKES sort SORT BY LINES (SETS FIELD SEPARATOR, THE
## sort -t OPTION, TO BE CTRL-A). FOR EXAMPLE,
## ** TO SORT STARTING AT THE SECOND LINE, USE: -a +1
## ** TO SORT STARTING AT THE FIFTH CHARACTER OF THIRD LINE: -a +2.4
##
# WORKS BY FIRST JOINING EACH CHUNK WITH A CTRL-A, LIKE THIS:
#
# Using C on the UNIX System^ABy Dave Curry^A250 pages, ISBN 0-937175-23-4
# Checking C Programs with lint^ABy Ian F. Darwin^A84 pages, ISBN 0-937175-30-7
#
# THEN SORTING AND SPLITTING AGAIN.
#
# Thanks to Greg Ubben for help on this.
files= sortopts=
# PARSE COMMAND LINE:
while :
do
case "$1" in
"") # OUT OF ARGUMENTS (WE HOPE...)
break
;;
-a) # USE CTRL-A AS SORT FIELD SEPARATOR (SO CAN PICK WHICH LINE OF
# THE RECORD TO SORT ON -- FOR EXAMPLE, +1 TO SORT ON LINE 2):
ctrla=`echo a | tr a '\001'`
sortopts="$sortopts -t$ctrla"
;;
-o) # WE CAN'T PASS -o TO sort BECAUSE USER WOULD GET WRONG OUTPUT:
echo "`basename $0` quitting: I don't have a -o option." 1>&2
exit 1
;;
-[Tyz])
# THE sort T, y, AND z OPTIONS HAVE AN ARGUMENT AFTER THEM.
sortopts="$sortopts $1 $2"
shift # GET RID OF ONE (WE'LL DO OTHER BELOW)
;;
[-+]*)
# SOME OTHER OPTION OR SORT FIELD:
sortopts="$sortopts $1"
;;
*) # IT'S A FILENAME (WE HOPE...)
files="$files $1"
;;
esac
shift
done
# Change newlines into CTRL-a's, print long line with extra CTRL-a at end:
gawk '{
gsub(/\n/,"\1");
print $0 "\1" }
' RS= $files |
# sort that text with $sortopts from above, change CTRL-a's to newlines:
sort $sortopts |
tr '\1' '\12'