1#!/bin/sh - 2# $OpenBSD: stests,v 1.4 2008/12/12 15:45:51 otto Exp $ 3# from: @(#)stests 8.1 (Berkeley) 6/6/93 4 5#Latest version. My sort passes all tests because I wrote it. 6#We differ only on 25E and 25H. 7#(I found at least one bug in constructing test 25, and was driven 8#to rewrite field parsing to clarify it.) 9# 10#In 25E, -k2.3,2.1b, the fields are not necessarily out of order. 11#Even if they were, it would be legal (11752-3), although certainly 12#justification for warning. 13# 14#On 25H, your answer is as defensible as mine. (Our suggestion 15#*1 backs mine.) 16 17 18# Tests for the Unix sort utility 19# Test Posix features except for locale. 20# Test some nonstandard features if present. 21 22# Other tests should be made for files too big to fit in memory. 23 24 25# Initialize switches for nonstandard features. 26# Use parenthesized settings for supported features. 27 28o=: # officially obsolescent features: +1 -2, misplaced -o (o=) 29g=: # -g numeric sort including e-format numbers (g=) 30M=: # -M sort by month names (M=) 31s=: # -s stable, do not compare raw bytes on equal keys (s=) 32y= # -y user-specified memory size (y=-y10000) 33 34# Detect what features are supported, assuming bad options cause 35# errors. Set switches accordingly. 36 37echo obsolescent and nonstandard features recognized, if any: 38if sort +0 </dev/null 2>/dev/null; then o= 39 echo ' +1 -2'; fi 40if sort /dev/null -o xx 2>/dev/null; then o= 41 echo ' displaced -o'; fi 42if sort -g </dev/null 2>/dev/null; then g= 43 echo ' -g g-format numbers'; fi 44if sort -M </dev/null 2>/dev/null; then M= 45 echo ' -M months'; fi 46if sort -s </dev/null 2>/dev/null; then s= 47 echo ' -s stable'; fi 48if sort -y10000 </dev/null 2>/dev/null; then y=-y10000 49 echo ' -y space'; fi 50if sort -z10000 </dev/null 2>/dev/null; then 51 echo ' -z size (not exercised)'; fi 52if sort -T. </dev/null 2>/dev/null; then 53 echo ' -T tempdir (not exercised)'; fi 54 55 56export TEST # major sequence number of test 57 58trap "rm -f -- -k in in1 out xx -k xsort linecount fields; exit" 0 1 2 13 15 59 60# xsort testno options 61# Sort file "in" with specified options. 62# Compare with file "out" if that is supplied, 63# otherwise make plausibility checks on output 64 65# "sum" must be dumb; insensitive to the 66# order of lines within a file. 67# System V sum is suitable; sum -5 is the v10 equivalent. 68 69PATH=.:$PATH 70export PATH 71cat <<'!' >xsort; chmod +x xsort 72 73 X=$1; shift 74 75 if sort "$@" in >xx && sort -c "$@" xx 76 then 77 if test -f out 78 then 79 cmp xx out >/dev/null && exit 0 80 echo $TEST$X comparison failed 81 else 82 test "`cksum -o2 <in`" = "`cksum -o2 <xx`" && exit 0 83 echo $TEST$X checksum failed 84 fi 85 else 86 echo $TEST$X failed 87 fi 88 exit 1 89! 90 91# linecount testno file count 92# declares the given "testno" to be in error if number of 93# lines in "file" differs from "count" 94 95cat <<'!' >linecount; chmod +x linecount 96awk 'END{ if(NR!='$3') print "'$TEST$1' failed" }' $2 97! 98 99rm -f out 100 101#--------------------------------------------------------------- 102TEST=01; echo $TEST # -c status, checksum 103 # obsolescent features go together 104cat <<! >in 105b 106a 107! 108rm -f out -o 109 110sort -c in 2>/dev/null && echo ${TEST}A failed 111 112xsort B || '"cksum"' is probably unsuitable - see comments 113 114$o sort +0 in -o in || echo ${TEST}c failed 115 116#--------------------------------------------------------------- 117TEST=02; echo $TEST # output from -c 118cat <<! >in 119x 120y 121! 122 123sort -cr in >out 2>xx && echo ${TEST}A failed 124test -s out && echo ${TEST}B failed 125test -s xx && echo option -c is noisy "(probably legal)" 126test -s xx || echo option -c is quiet "(legal, not classical)" 127 128#--------------------------------------------------------------- 129TEST=03; echo $TEST # -n 130cat <<! >in 131-99.0 132-99.1 133-.0002 134-10 1352 1360010.000000000000000000000000000000000001 13710 1383x 139x 140! 141cat <<! >out 142-99.1 143-99.0 144-10 145-.0002 146x 1472 1483x 14910 1500010.000000000000000000000000000000000001 151! 152 153xsort "" -n 154 155#--------------------------------------------------------------- 156TEST=04; echo $TEST # -b without fields, piping, -c status return 157cat <<! >in 158 b 159 a 160! 161cp in out 162 163xsort A -b 164 165cat in | sort | cat >xx 166cmp xx out >/dev/null || echo ${TEST}B failed 167 168sort in | sort -cr 2>/dev/null && echo ${TEST}C failed 169 170#--------------------------------------------------------------- 171TEST=05; echo $TEST # fields, reverse fields, -c status return 172cat <<! >in 173b b p 174a b q 175x a 176! 177cat <<! >out 178x a 179a b q 180b b p 181! 182 183$o xsort A +1 -2 184 185$o xsort B +1 -2 +2r 186 187xsort C -k 2,2 188 189xsort D -k 2,2 -k 3r 190 191xsort E -k 2,2.0 192 193xsort F -k 2,2 -k 1,1 -k 3 194 195sort -c -k 2 in 2>/dev/null && echo ${TEST}G failed 196 197#--------------------------------------------------------------- 198TEST=06; echo $TEST # -t 199cat <<! >in 200a: 201a! 202! 203cp in out 204 205$o xsort A -t : -r +0 206 207$o xsort B -t : +0 -1 208 209xsort C -t : -r -k 1 210 211xsort D -t : -k 1,1 212 213#--------------------------------------------------------------- 214TEST=07; echo $TEST # -t, character positions in fields 215 # -t: as 1 arg is not strictly conforming, but classical 216cat <<! >in 217: ab 218:bac 219! 220cat <<! >out 221:bac 222: ab 223! 224 225$o xsort A -b -t: +1.1 226 227$o xsort B -t: +1.1r 228 229xsort C -b -t: -k 2.2 230 231xsort D -t: -k 2.2r 232 233#--------------------------------------------------------------- 234TEST=08; echo $TEST # space and tab as -t characters 235cat <<! >in 236 b c 237 b c 238 b c 239! 240cp in out 241 242xsort A -t ' ' -k2,2 243 244xsort B -t ' ' -k2.1,2.0 245 246cat <<! >out 247 b c 248 b c 249 b c 250! 251 252xsort C -t ' ' -k2,2 253 254xsort D -t ' ' -k2.1,2.0 255 256cat <<! >out 257 b c 258 b c 259 b c 260! 261 262xsort E -k2 263 264cat <<! >out 265 b c 266 b c 267 b c 268! 269 270xsort F -k2b 271 272#--------------------------------------------------------------- 273TEST=09; echo $TEST # alphabetic as -t character 274cat <<! >in 275zXa 276yXa 277zXb 278! 279cp in out 280 281xsort "" -tX -k2 -k1r,1 282 283#--------------------------------------------------------------- 284TEST=10; echo $TEST # -m 285cat <<! >in 286a 287ab 288ab 289bc 290ca 291! 292cat <<! >in1 293Z 294a 295aa 296ac 297c 298! 299cat <<! >out 300Z 301a 302a 303aa 304ab 305ab 306ac 307bc 308c 309ca 310! 311 312sort -m in in1 >xx 313cmp xx out >/dev/null || echo $TEST failed 314 315#--------------------------------------------------------------- 316TEST=11; echo $TEST # multiple files, -o overwites input, -m, -mu 317cat <<! >in 318a 319b 320c 321d 322! 323 324sort -o xx in in in in in in in in in in in in in in in in in 325linecount A xx 68 326sort -o in -mu in in in in in in in in in in in in in in in in in 327linecount B in 4 328sort -o in -m in in in in in in in in in in in in in in in in in 329 330cmp in xx >/dev/null || echo ${TEST}C failed 331 332#--------------------------------------------------------------- 333TEST=12; echo $TEST # does -mu pick the first among equals? 334cat <<! >in 3353B 3363b 3373B2 338~3B2 3394.1 34041 3415 3425. 343! 344cat <<! >out 3453B 3463B2 3474.1 3485 349! 350 351xsort A -mudf || echo "(other behavior is legal, not classical)" 352 353xsort B -mudf -k1 || echo "(other behavior is legal, not classical)" 354 355#--------------------------------------------------------------- 356TEST=13; echo $TEST # long records (>8000 bytes, keys >16000), -r 357awk ' 358BEGIN { x="x" 359 for(i=1; i<=12; i++) x = x x 360 for(i=15; i<=25; i++) print x i 361}' >in 362awk ' 363BEGIN { x="x" 364 for(i=1; i<=12; i++) x = x x 365 for(i=25; i>=15; i--) print x i 366}' >out 367 368xsort A -r 369 370xsort B -k 1,1r -k 1 371 372#--------------------------------------------------------------- 373TEST=14; echo $TEST "(3 long parts)" 374awk 'BEGIN { for(i=0; i<100000; i++) print rand() }' | grep -v e >in 375rm -f out 376 377xsort A; echo $TEST "(part A done)" 378 379xsort B -n; echo $TEST "(part B done)" 380 381# next test is unclean: xx is a hidden side-effect of xsort 382 383awk ' 384 $0 < x { print "test '${TEST}C' failed"; exit } 385 $0 "" != x { print >"out"; x = $0 } 386' xx 387 388xsort C -n -u 389 390#--------------------------------------------------------------- 391TEST=15; echo $TEST "(long)" # force intermediate files if possible 392awk 'BEGIN { for(i=0; i<20000; i++) print rand() }' >in 393rm -f out 394 395xsort A -r $y 396 397sort -r in | awk '$0 "x" != x { print ; x = $0 "x" }' >out 398 399xsort B -u -r $y 400 401#--------------------------------------------------------------- 402TEST=16; echo $TEST # -nr, -nm, file name - 403awk 'BEGIN { for(i=-100; i<=100; i+=2) printf "%.10d\n", i }' >in 404 405awk 'BEGIN { for(i=-99; i<=100; i+=2) print i }' | sort -nr in - >xx 406awk '$0+0 != 101-NR { print "'${TEST}A' failed"; exit }' xx 407 408awk 'BEGIN { for(i=-99; i<=100; i+=2) print i }' | sort -mn in - >xx 409awk '$0+0 != -101+NR { print "'${TEST}B' failed"; exit }' xx 410 411#--------------------------------------------------------------- 412TEST=17; echo $TEST # -d, fields without end, modifier override 413cat <<! >in 414a-B 415a+b 416a b 417A+b 418a b 419! 420cat <<! >out 421a b 422a b 423A+b 424a-B 425a+b 426! 427 428$o xsort A -df +0 +0d 429 430xsort B -df -k 1 -k 1d 431 432#--------------------------------------------------------------- 433TEST=18; echo $TEST # -u on key only 434cat <<! >in 43512 y 43613 z 43712 x 438! 439cat <<! >out 44012 x 44112 y 44213 z 443! 444 445$o xsort A +0 -1 446 447xsort B -k 1,1 448 449sort -u -k 1,1 in >xx 450linecount C xx 2 451 452#--------------------------------------------------------------- 453TEST=19; echo $TEST # -i, -d, -f 454cat <<! >xx.c 455run(i,j){ for( ; i<=j; i++) printf("%.3o %c\n",i,i); } 456main(){ run(0, 011); /* 012=='\n' */ 457 run(013, 0377); } 458! 459cc xx.c 460a.out >in 461cat <<! >xx.c 462run(i,j){ for( ; i<=j; i++) printf("%.3o %c\n",i,i); } 463main(){ run(0, 011); 464 run(013, ' '-1); 465 run(0177, 0377); 466 run(' ', 0176); } 467! 468cc xx.c 469a.out >out 470 471xsort A -i -k 2 472 473cat <<! >xx.c 474run(i,j){ for( ; i<=j; i++) printf("%.3o %c\n",i,i); } 475main(){ run(0, 010); /* 011=='\t', 012=='\n' */ 476 run(013, ' '-1); 477 run(' '+1, '0'-1); 478 run('9'+1, 'A'-1); 479 run('Z'+1, 'a'-1); 480 run('z'+1, 0377); 481 run('\t', '\t'); 482 run(' ', ' '); 483 run('0', '9'); 484 run('A', 'Z'); 485 run('a', 'z'); } 486! 487cc xx.c 488a.out >out 489 490xsort B -d -k 2 491 492cat <<! >xx.c 493run(i,j){ for( ; i<=j; i++) printf("%.3o %c\n",i,i); } 494main(){ int i; 495 run(0, 011); 496 run(013, 'A'-1); 497 for(i='A'; i<='Z'; i++) 498 printf("%.3o %c\n%.3o %c\n",i,i,i+040,i+040); 499 run('Z'+1, 'a'-1); 500 run('z'+1, 0377); } 501! 502cc xx.c 503a.out >out 504rm xx.c 505 506xsort C -f -k 2 507 508#--------------------------------------------------------------- 509TEST=20; echo $TEST # -d, -f, -b applies only to fields 510cat <<! >in 511 b 512'C 513a 514! 515cp in out 516 517xsort A -d 518 519xsort B -f 520 521cat <<! >out 522 b 523a 524'C 525! 526 527xsort C -dfb 528 529#--------------------------------------------------------------- 530TEST=21; echo $TEST # behavior of null bytes 531cat <<'!' >xx.c 532main() { printf("%cb\n%ca\n",0,0); } 533! 534cc xx.c 535a.out >in 536sort in >xx 537cmp in xx >/dev/null && echo ${TEST}A failed 538test "`wc -c <in`" = "`wc -c <xx`" || echo ${TEST}B failed 539rm xx.c a.out 540 541#--------------------------------------------------------------- 542TEST=22; echo $TEST # field limits 543cat <<! >in 544a 2 545a 1 546b 2 547b 1 548! 549cat <<! >out 550b 1 551b 2 552a 1 553a 2 554! 555 556xsort "" -r -k1,1 -k2n 557 558#--------------------------------------------------------------- 559TEST=23; echo $TEST # empty file 560 561sort -o xx </dev/null 562cmp xx /dev/null 2>/dev/null || echo ${TEST}A failed 563 564sort -c </dev/null || echo ${TEST}B failed 565 566sort -cu </dev/null || echo ${TEST}C failed 567 568#--------------------------------------------------------------- 569TEST=24; echo $TEST # many fields 570cat <<! >in 5710:2:3:4:5:6:7:8:9 5721:1:3:4:5:6:7:8:9 5731:2:2:4:5:6:7:8:9 5741:2:3:3:5:6:7:8:9 5751:2:3:4:4:6:7:8:9 5761:2:3:4:5:5:7:8:9 5771:2:3:4:5:6:6:8:9 5781:2:3:4:5:6:7:7:9 5791:2:3:4:5:6:7:8:8 580! 581cat <<! >out 5821:2:3:4:5:6:7:8:8 5831:2:3:4:5:6:7:7:9 5841:2:3:4:5:6:6:8:9 5851:2:3:4:5:5:7:8:9 5861:2:3:4:4:6:7:8:9 5871:2:3:3:5:6:7:8:9 5881:2:2:4:5:6:7:8:9 5891:1:3:4:5:6:7:8:9 5900:2:3:4:5:6:7:8:9 591! 592 593xsort "" -t: -k9 -k8 -k7 -k6 -k5 -k4 -k3 -k2 -k1 594 595#--------------------------------------------------------------- 596TEST=25; echo $TEST # variously specified alpha fields 597 # numbers give the correct orderings 598cat <<! >in 59901:04:19:01:16:01:21:01 a 60002:03:13:15:13:19:15:02 a 60103:02:07:09:07:13:09:03 a 60204:01:01:03:01:07:03:04 a 60305:08:20:16:17:02:20:05 aa 60406:07:14:18:14:20:14:06 aa 60507:06:08:10:08:14:08:07 aa 60608:05:02:04:02:08:02:08 aa 60709:16:22:02:22:04:24:13 b 60810:15:16:20:19:22:18:14 b 60911:14:10:12:10:16:12:15 b 61012:13:04:06:04:10:06:16 b 61113:24:24:22:24:06:22:21 bb 61214:23:18:24:21:24:16:22 bb 61315:22:12:14:12:18:10:23 bb 61416:21:06:08:06:12:04:24 bb 61517:12:21:21:18:03:19:09 ab 61618:11:15:19:15:21:13:10 ab 61719:10:09:11:09:15:07:11 ab 61820:09:03:05:03:09:01:12 ab 61921:20:23:17:23:05:23:17 ba 62022:19:17:23:20:23:17:18 ba 62123:18:11:13:11:17:11:19 ba 62224:17:05:07:05:11:05:20 ba 623! 624sort -k2b -k2 in >xx && 625 sort -c -t: -k2n xx 2>/dev/null || echo ${TEST}A failed 626sort -k2,2.1b -k2 in >xx && 627 sort -c -t: -k3n xx 2>/dev/null || echo ${TEST}B failed 628sort -k2.3 -k2 in >xx && 629 sort -c -t: -k4n xx 2>/dev/null || echo ${TEST}C failed 630sort -k2b,2.3 -k2 in >xx && 631 sort -c -t: -k5n xx 2>/dev/null || echo ${TEST}D failed 632sort -k2.3,2.1b -k2 in >xx && 633 sort -c -t: -k6n xx 2>/dev/null || echo ${TEST}E failed 634sort -k2,2.1b -k2r in >xx && 635 sort -c -t: -k7n xx 2>/dev/null || echo ${TEST}F failed 636sort -b -k2,2 -k2 in >xx && 637 sort -c -t: -k8n xx 2>/dev/null || echo ${TEST}G failed 638sort -b -k2,2b -k2 in >xx && # perhaps same as G 639 sort -c -t: -k3n xx 2>/dev/null || echo ${TEST}H failed\ 640 "(standard is not clear on this)" 641 642#--------------------------------------------------------------- 643TEST=26; echo $TEST # empty fields, out of bounds fields 644cat <<! >in 6450 5 6461 4 6472 3 6483 2 6494 1 6505 0 651! 652cp in out 653 654xsort "" -k2.2,2.1 -k2.3,2.4 655 656#--------------------------------------------------------------- 657TEST=27; echo $TEST # displaced -o 658rm -f out 659 660$o sort /dev/null -o out || $o echo ${TEST}B failed 661$o test -f out || $o echo ${TEST}C failed 662 663#--------------------------------------------------------------- 664TEST=28; echo $TEST # apparently nonmonotone field specs 665cat <<! >in 666aaaa c 667x a 6680 b 669! 670cp in out 671 672$o xsort A +1 -0.3 +1.4 -1.5 673 674xsort B -k2,1.3 -k2.5,2.5 675 676#--------------------------------------------------------------- 677TEST=29; echo $TEST # determination of end of option list 678cat >-k <<! 679x 680! 681rm -f out -c 682 683sort -- -k </dev/null >xx || echo ${TEST}A argument failed 684cmp xx -k || echo ${TEST}A comparison failed 685 686sort - -c </dev/null 2>/dev/null && echo ${TEST}B failed 687rm -- -k 688 689#--------------------------------------------------------------- 690TEST=30; echo $TEST # missing newline 691awk 'BEGIN{ printf "%s", "x"}' | sort >xx 692wc -c <xx | awk '$1!=2{ print "'${TEST}' failed" }' 693 694#--------------------------------------------------------------- 695TEST=31; echo $TEST # -M, multiple fields 696cat <<! >in 697jan 10 1900 698Feb 26 1900 699feb 25 1900 700January xx 1900 701August 11 1900 702jan 15 1990 703feb 22 1990 704mar 15 1990 705apr 1 1990 706may 45 1990 707jun 14 1990 708jul 4 1990 709aug 1~ 1990 710aug 11 1990 711sep 1 1990 712oct 12 1990 713nov 24 1990 714dec 25 1990 715never 3 1990 716 Dec 25 1990 717! 718cat <<! >out 719January xx 1900 720jan 10 1900 721feb 25 1900 722Feb 26 1900 723August 11 1900 724never 3 1990 725jan 15 1990 726feb 22 1990 727mar 15 1990 728apr 1 1990 729may 45 1990 730jun 14 1990 731jul 4 1990 732aug 1~ 1990 733aug 11 1990 734sep 1 1990 735oct 12 1990 736nov 24 1990 737 Dec 25 1990 738dec 25 1990 739! 740 741$M xsort "" -k3n -k1M -k2n 742 743#--------------------------------------------------------------- 744TEST=32; echo $TEST # -M case insensitivity, -r 745cat <<! >in 746x 747june 748january 749december 750! 751cat <<! >out 752december 753june 754january 755x 756! 757 758$M xsort "" -Mr 759 760#--------------------------------------------------------------- 761TEST=33; echo $TEST # -g 762cat <<! >in 7632 7641 76510 766.2 7671e 7681E1 7691e. 770! 771cat <<! >out 772.2 7731 7741e 7751e. 7762 77710 7781E1 779! 780 781$g xsort "" -g 782 783#--------------------------------------------------------------- 784TEST=34; echo $TEST # -g wide operands 785cat <<! >in 786.99999999999999999999 787099999999999999999999e-21 788099999999999999999999e-19 789.1e1 790! 791cat <<! >out 792099999999999999999999e-21 793.99999999999999999999 794.1e1 795099999999999999999999e-19 796! 797 798$g xsort A -g 799 800cat <<! >out 801.1e1 802.99999999999999999999 803099999999999999999999e-19 804099999999999999999999e-21 805! 806 807xsort B -n 808 809#--------------------------------------------------------------- 810TEST=35; echo $TEST #-g, -u with different fp reps 811cat <<! >in 812+0 813-0 8140.10 815+.1 816-.1 817-100e-3 818x 819! 820cat <<! >out 821-.1 822-100e-3 823+0 824-0 825x 826+.1 8270.10 828! 829 830$g xsort A -g 831 832$g sort -gu in >xx && $g sort -c -gu xx || echo ${TEST}B failed 833$g linecount C xx 3 834 835#--------------------------------------------------------------- 836TEST=36; echo $TEST # -s 837cat <<! >in 838a 2 839b 1 840c 2 841a 1 842b 2 843c 1 844! 845cat <<! >out 846a 2 847a 1 848b 1 849b 2 850c 2 851c 1 852! 853 854$s xsort "" -s -k1,1 855 856#--------------------------------------------------------------- 857TEST=37; echo $TEST # -s, multiple files 858cat <<! >in 859c 2 860a 2 861! 862cat <<! >in1 863c 1 864b 1 865a 1 866! 867cat <<! >out 868c 2 869b 1 870a 2 871! 872 873$s sort -smru -k1,1 in in in1 in1 >xx 874$s cmp xx out >/dev/null || echo $TEST failed 875 876#--------------------------------------------------------------- 877TEST=38; echo $TEST # -s 878$s awk ' 879 BEGIN { 880 for(i=1; i<50; i++) 881 for(j=1; j<=i; j++) { 882 print i, 2 >"in" 883 print i, 1 >"in1" 884 } 885 }' 886 887$s sort -m -s -k1,1n in in1 >out 888 889$s awk ' 890 func stop() { print "'$TEST' failed"; exit } 891 $1!=last1 { if(count!=last1 || $2!=2) stop(); 892 count = 0} 893 $1==last1 && $2!=last2 { if(count!=last1 || $2!=1) stop(); 894 count = 0 } 895 { count++; last1 = $1; last2 = $2 } 896 ' out 897 898#--------------------------------------------------------------- 899TEST=39; echo $TEST # sort already sorted dictionary 900 901dict=/usr/share/dict/words 902 903sort -f $dict > out 904 905cmp -s out $dict || echo $TEST failed - sort -f $dict 906 907#--------------------------------------------------------------- 908TEST=40; echo "$TEST (long)" # long lines test 909 910line1="abcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghij" 911line2="bcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghijklmnopqrstabcdefghijk" 912 913rm -f in out 914 915# generate two out-of-order long lines (roughly 70 KB each), and try sort 916# them 917awk ' 918BEGIN { 919 line1 = "'"${line1}"'" 920 line2 = "'"${line2}"'" 921 for(i=0; i<10; i++) { 922 line1 = line1 line1 923 line2 = line2 line2 924 } 925 print line2 > "in" 926 print line1 > "in" 927 928 print line1 > "out" 929 print line2 > "out" 930}' 931 932xsort "A" 933 934# generate already sorted file using $dict, only append space and 935# long string to each line to make lines longer than usual 936# use only first 200 lines (sort file approx. 14MB) 937cat $dict | awk ' 938BEGIN { 939 line = "'"$line1"'" 940 for(i=0; i<10; i++) 941 line = line line 942 idx = 0 943} 944{ print $1 " " line; if (idx++ > 200) exit 0 }' > in 945ln -sf in out 946xsort "B" -f 947rm -f in out 948#--------------------------------------------------------------- 949TEST=41; echo "$TEST" 950 951# sort okay at reps=87381, broken at 87382 952# on 64-bit platforms, it's already broken at 87382/2 953 954awk ' 955BEGIN { 956 reps=87382 957 i=0 958 while (i++ < reps) { 959 print "lo0" > "in" 960 print "ce0" > "in" 961 print "ce1" > "in" 962 } 963 print "ce0" > "out" 964 print "ce1" > "out" 965 print "lo0" > "out" 966 967}' 968 969xsort A -u 970