CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 16 Jul 2025 00:34:57 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090210083322
location: https://web.archive.org/web/20090210083322/https://examples.oreilly.com/upt2/split/chunksort
server-timing: captures_list;dur=0.512879, exclusion.robots;dur=0.020271, exclusion.robots.policy;dur=0.009708, esindex;dur=0.009824, cdx.remote;dur=12.475669, LoadShardBlock;dur=561.845491, PetaboxLoader3.datanode;dur=83.029006, PetaboxLoader3.resolve;dur=352.873472
x-app-server: wwwb-app213
x-ts: 302
x-tr: 596
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app213; 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: Wed, 16 Jul 2025 00:34:58 GMT
content-type: text/plain
content-length: 1944
x-archive-orig-date: Tue, 10 Feb 2009 08:33:22 GMT
x-archive-orig-server: Apache
x-archive-orig-last-modified: Mon, 31 Mar 2008 18:10:12 GMT
x-archive-orig-etag: "1bac1b-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: Tue, 10 Feb 2009 08:33:22 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="Sun, 18 May 2008 20:43:47 GMT", ; rel="memento"; datetime="Tue, 10 Feb 2009 08:33:22 GMT", ; rel="next memento"; datetime="Wed, 30 Sep 2015 16:46:00 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_8_20090210075601_crawl103-c/52_8_20090210083255_crawl100.arc.gz
server-timing: captures_list;dur=0.625512, exclusion.robots;dur=0.022450, exclusion.robots.policy;dur=0.010500, esindex;dur=0.011703, cdx.remote;dur=31.567242, LoadShardBlock;dur=114.136005, PetaboxLoader3.datanode;dur=118.133347, load_resource;dur=476.335833, PetaboxLoader3.resolve;dur=391.257755
x-app-server: wwwb-app213
x-ts: 200
x-tr: 644
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'