diff options
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 515 | ||||
-rw-r--r-- | doc/gawk.texi | 26 | ||||
-rw-r--r-- | doc/gawktexi.in | 26 |
4 files changed, 315 insertions, 257 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index 3a8688b1..d4a124b2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2020-01-01 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in (History Sorting): Supply a shorter version of the + program. Thanks to Rick van Rein <rick@openfortress.nl>. + 2019-12-22 Arnold D. Robbins <arnold@skeeve.com> * implementation-notes.txt: New file. diff --git a/doc/gawk.info b/doc/gawk.info index 60a24f81..5c60be61 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -1,6 +1,6 @@ This is gawk.info, produced by makeinfo version 6.7 from gawk.texi. -Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2019 +Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2020 Free Software Foundation, Inc. @@ -37,7 +37,7 @@ General Introduction This file documents 'awk', a program that you can use to select particular records in a file and perform operations upon them. - Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2019 + Copyright (C) 1989, 1991, 1992, 1993, 1996-2005, 2007, 2009-2020 Free Software Foundation, Inc. @@ -19141,6 +19141,19 @@ information. For example, using the following 'print' statement in the This works because 'data[$0]' is incremented each time a line is seen. + Rick van Rein offers the following one-liner to do the same job of +removing duplicates from unsorted text: + + awk '{ if (! seen[$0]++) print }' + + This can be simplified even further, at the risk of becoming almost +too obscure: + + awk '! seen[$0]++' + +This version uses the expression as a pattern, relying on 'awk''s +default action of printing the line when the pattern is true. + File: gawk.info, Node: Extract Program, Next: Simple Sed, Prev: History Sorting, Up: Miscellaneous Programs @@ -37451,255 +37464,255 @@ Node: Labels Program772554 Ref: Labels Program-Footnote-1775905 Node: Word Sorting775989 Node: History Sorting780061 -Node: Extract Program781896 -Node: Simple Sed789950 -Node: Igawk Program793024 -Ref: Igawk Program-Footnote-1807355 -Ref: Igawk Program-Footnote-2807557 -Ref: Igawk Program-Footnote-3807679 -Node: Anagram Program807794 -Node: Signature Program810856 -Node: Programs Summary812103 -Node: Programs Exercises813317 -Ref: Programs Exercises-Footnote-1817446 -Node: Advanced Features817537 -Node: Nondecimal Data819527 -Node: Array Sorting821118 -Node: Controlling Array Traversal821818 -Ref: Controlling Array Traversal-Footnote-1830186 -Node: Array Sorting Functions830304 -Ref: Array Sorting Functions-Footnote-1835395 -Node: Two-way I/O835591 -Ref: Two-way I/O-Footnote-1843312 -Ref: Two-way I/O-Footnote-2843499 -Node: TCP/IP Networking843581 -Node: Profiling846699 -Node: Advanced Features Summary855714 -Node: Internationalization857558 -Node: I18N and L10N859038 -Node: Explaining gettext859725 -Ref: Explaining gettext-Footnote-1865617 -Ref: Explaining gettext-Footnote-2865802 -Node: Programmer i18n865967 -Ref: Programmer i18n-Footnote-1870916 -Node: Translator i18n870965 -Node: String Extraction871759 -Ref: String Extraction-Footnote-1872891 -Node: Printf Ordering872977 -Ref: Printf Ordering-Footnote-1875763 -Node: I18N Portability875827 -Ref: I18N Portability-Footnote-1878283 -Node: I18N Example878346 -Ref: I18N Example-Footnote-1881621 -Ref: I18N Example-Footnote-2881694 -Node: Gawk I18N881803 -Node: I18N Summary882452 -Node: Debugger883793 -Node: Debugging884793 -Node: Debugging Concepts885234 -Node: Debugging Terms887043 -Node: Awk Debugging889618 -Ref: Awk Debugging-Footnote-1890563 -Node: Sample Debugging Session890695 -Node: Debugger Invocation891229 -Node: Finding The Bug892615 -Node: List of Debugger Commands899089 -Node: Breakpoint Control900422 -Node: Debugger Execution Control904116 -Node: Viewing And Changing Data907478 -Node: Execution Stack911019 -Node: Debugger Info912656 -Node: Miscellaneous Debugger Commands916727 -Node: Readline Support921789 -Node: Limitations922685 -Node: Debugging Summary925239 -Node: Namespaces926518 -Node: Global Namespace927629 -Node: Qualified Names929027 -Node: Default Namespace930026 -Node: Changing The Namespace930767 -Node: Naming Rules932381 -Node: Internal Name Management934229 -Node: Namespace Example935271 -Node: Namespace And Features937833 -Node: Namespace Summary939268 -Node: Arbitrary Precision Arithmetic940745 -Node: Computer Arithmetic942232 -Ref: table-numeric-ranges945998 -Ref: table-floating-point-ranges946491 -Ref: Computer Arithmetic-Footnote-1947149 -Node: Math Definitions947206 -Ref: table-ieee-formats950522 -Ref: Math Definitions-Footnote-1951125 -Node: MPFR features951230 -Node: FP Math Caution952948 -Ref: FP Math Caution-Footnote-1954020 -Node: Inexactness of computations954389 -Node: Inexact representation955349 -Node: Comparing FP Values956709 -Node: Errors accumulate957950 -Node: Getting Accuracy959383 -Node: Try To Round962093 -Node: Setting precision962992 -Ref: table-predefined-precision-strings963689 -Node: Setting the rounding mode965519 -Ref: table-gawk-rounding-modes965893 -Ref: Setting the rounding mode-Footnote-1969824 -Node: Arbitrary Precision Integers970003 -Ref: Arbitrary Precision Integers-Footnote-1973178 -Node: Checking for MPFR973327 -Node: POSIX Floating Point Problems974801 -Ref: POSIX Floating Point Problems-Footnote-1979086 -Node: Floating point summary979124 -Node: Dynamic Extensions981314 -Node: Extension Intro982867 -Node: Plugin License984133 -Node: Extension Mechanism Outline984930 -Ref: figure-load-extension985369 -Ref: figure-register-new-function986934 -Ref: figure-call-new-function988026 -Node: Extension API Description990088 -Node: Extension API Functions Introduction991730 -Ref: table-api-std-headers993566 -Node: General Data Types997431 -Ref: General Data Types-Footnote-11005792 -Node: Memory Allocation Functions1006091 -Ref: Memory Allocation Functions-Footnote-11010301 -Node: Constructor Functions1010400 -Node: Registration Functions1013986 -Node: Extension Functions1014671 -Node: Exit Callback Functions1019993 -Node: Extension Version String1021243 -Node: Input Parsers1021906 -Node: Output Wrappers1034627 -Node: Two-way processors1039139 -Node: Printing Messages1041404 -Ref: Printing Messages-Footnote-11042575 -Node: Updating ERRNO1042728 -Node: Requesting Values1043467 -Ref: table-value-types-returned1044204 -Node: Accessing Parameters1045140 -Node: Symbol Table Access1046375 -Node: Symbol table by name1046887 -Ref: Symbol table by name-Footnote-11049911 -Node: Symbol table by cookie1050039 -Ref: Symbol table by cookie-Footnote-11054224 -Node: Cached values1054288 -Ref: Cached values-Footnote-11057824 -Node: Array Manipulation1057977 -Ref: Array Manipulation-Footnote-11059068 -Node: Array Data Types1059105 -Ref: Array Data Types-Footnote-11061763 -Node: Array Functions1061855 -Node: Flattening Arrays1066353 -Node: Creating Arrays1073329 -Node: Redirection API1078096 -Node: Extension API Variables1080929 -Node: Extension Versioning1081640 -Ref: gawk-api-version1082069 -Node: Extension GMP/MPFR Versioning1083800 -Node: Extension API Informational Variables1085428 -Node: Extension API Boilerplate1086501 -Node: Changes from API V11090475 -Node: Finding Extensions1092047 -Node: Extension Example1092606 -Node: Internal File Description1093404 -Node: Internal File Ops1097484 -Ref: Internal File Ops-Footnote-11108834 -Node: Using Internal File Ops1108974 -Ref: Using Internal File Ops-Footnote-11111357 -Node: Extension Samples1111631 -Node: Extension Sample File Functions1113160 -Node: Extension Sample Fnmatch1120809 -Node: Extension Sample Fork1122296 -Node: Extension Sample Inplace1123514 -Node: Extension Sample Ord1127139 -Node: Extension Sample Readdir1127975 -Ref: table-readdir-file-types1128864 -Node: Extension Sample Revout1129931 -Node: Extension Sample Rev2way1130520 -Node: Extension Sample Read write array1131260 -Node: Extension Sample Readfile1133202 -Node: Extension Sample Time1134297 -Node: Extension Sample API Tests1136049 -Node: gawkextlib1136541 -Node: Extension summary1139459 -Node: Extension Exercises1143161 -Node: Language History1144403 -Node: V7/SVR3.11146059 -Node: SVR41148211 -Node: POSIX1149645 -Node: BTL1151025 -Node: POSIX/GNU1151754 -Node: Feature History1157532 -Node: Common Extensions1173725 -Node: Ranges and Locales1175008 -Ref: Ranges and Locales-Footnote-11179624 -Ref: Ranges and Locales-Footnote-21179651 -Ref: Ranges and Locales-Footnote-31179886 -Node: Contributors1180107 -Node: History summary1186060 -Node: Installation1187440 -Node: Gawk Distribution1188384 -Node: Getting1188868 -Node: Extracting1189831 -Node: Distribution contents1191469 -Node: Unix Installation1197949 -Node: Quick Installation1198631 -Node: Shell Startup Files1201045 -Node: Additional Configuration Options1202134 -Node: Configuration Philosophy1204449 -Node: Non-Unix Installation1206818 -Node: PC Installation1207278 -Node: PC Binary Installation1208116 -Node: PC Compiling1208551 -Node: PC Using1209668 -Node: Cygwin1213221 -Node: MSYS1214445 -Node: VMS Installation1214946 -Node: VMS Compilation1215737 -Ref: VMS Compilation-Footnote-11216966 -Node: VMS Dynamic Extensions1217024 -Node: VMS Installation Details1218709 -Node: VMS Running1220962 -Node: VMS GNV1225241 -Node: VMS Old Gawk1225976 -Node: Bugs1226447 -Node: Bug address1227110 -Node: Usenet1230092 -Node: Maintainers1231096 -Node: Other Versions1232357 -Node: Installation summary1239445 -Node: Notes1240647 -Node: Compatibility Mode1241441 -Node: Additions1242223 -Node: Accessing The Source1243148 -Node: Adding Code1244585 -Node: New Ports1250804 -Node: Derived Files1255179 -Ref: Derived Files-Footnote-11260839 -Ref: Derived Files-Footnote-21260874 -Ref: Derived Files-Footnote-31261472 -Node: Future Extensions1261586 -Node: Implementation Limitations1262244 -Node: Extension Design1263427 -Node: Old Extension Problems1264571 -Ref: Old Extension Problems-Footnote-11266089 -Node: Extension New Mechanism Goals1266146 -Ref: Extension New Mechanism Goals-Footnote-11269510 -Node: Extension Other Design Decisions1269699 -Node: Extension Future Growth1271812 -Node: Notes summary1272648 -Node: Basic Concepts1273806 -Node: Basic High Level1274487 -Ref: figure-general-flow1274769 -Ref: figure-process-flow1275454 -Ref: Basic High Level-Footnote-11278755 -Node: Basic Data Typing1278940 -Node: Glossary1282268 -Node: Copying1314106 -Node: GNU Free Documentation License1351649 -Node: Index1376769 +Node: Extract Program782286 +Node: Simple Sed790340 +Node: Igawk Program793414 +Ref: Igawk Program-Footnote-1807745 +Ref: Igawk Program-Footnote-2807947 +Ref: Igawk Program-Footnote-3808069 +Node: Anagram Program808184 +Node: Signature Program811246 +Node: Programs Summary812493 +Node: Programs Exercises813707 +Ref: Programs Exercises-Footnote-1817836 +Node: Advanced Features817927 +Node: Nondecimal Data819917 +Node: Array Sorting821508 +Node: Controlling Array Traversal822208 +Ref: Controlling Array Traversal-Footnote-1830576 +Node: Array Sorting Functions830694 +Ref: Array Sorting Functions-Footnote-1835785 +Node: Two-way I/O835981 +Ref: Two-way I/O-Footnote-1843702 +Ref: Two-way I/O-Footnote-2843889 +Node: TCP/IP Networking843971 +Node: Profiling847089 +Node: Advanced Features Summary856104 +Node: Internationalization857948 +Node: I18N and L10N859428 +Node: Explaining gettext860115 +Ref: Explaining gettext-Footnote-1866007 +Ref: Explaining gettext-Footnote-2866192 +Node: Programmer i18n866357 +Ref: Programmer i18n-Footnote-1871306 +Node: Translator i18n871355 +Node: String Extraction872149 +Ref: String Extraction-Footnote-1873281 +Node: Printf Ordering873367 +Ref: Printf Ordering-Footnote-1876153 +Node: I18N Portability876217 +Ref: I18N Portability-Footnote-1878673 +Node: I18N Example878736 +Ref: I18N Example-Footnote-1882011 +Ref: I18N Example-Footnote-2882084 +Node: Gawk I18N882193 +Node: I18N Summary882842 +Node: Debugger884183 +Node: Debugging885183 +Node: Debugging Concepts885624 +Node: Debugging Terms887433 +Node: Awk Debugging890008 +Ref: Awk Debugging-Footnote-1890953 +Node: Sample Debugging Session891085 +Node: Debugger Invocation891619 +Node: Finding The Bug893005 +Node: List of Debugger Commands899479 +Node: Breakpoint Control900812 +Node: Debugger Execution Control904506 +Node: Viewing And Changing Data907868 +Node: Execution Stack911409 +Node: Debugger Info913046 +Node: Miscellaneous Debugger Commands917117 +Node: Readline Support922179 +Node: Limitations923075 +Node: Debugging Summary925629 +Node: Namespaces926908 +Node: Global Namespace928019 +Node: Qualified Names929417 +Node: Default Namespace930416 +Node: Changing The Namespace931157 +Node: Naming Rules932771 +Node: Internal Name Management934619 +Node: Namespace Example935661 +Node: Namespace And Features938223 +Node: Namespace Summary939658 +Node: Arbitrary Precision Arithmetic941135 +Node: Computer Arithmetic942622 +Ref: table-numeric-ranges946388 +Ref: table-floating-point-ranges946881 +Ref: Computer Arithmetic-Footnote-1947539 +Node: Math Definitions947596 +Ref: table-ieee-formats950912 +Ref: Math Definitions-Footnote-1951515 +Node: MPFR features951620 +Node: FP Math Caution953338 +Ref: FP Math Caution-Footnote-1954410 +Node: Inexactness of computations954779 +Node: Inexact representation955739 +Node: Comparing FP Values957099 +Node: Errors accumulate958340 +Node: Getting Accuracy959773 +Node: Try To Round962483 +Node: Setting precision963382 +Ref: table-predefined-precision-strings964079 +Node: Setting the rounding mode965909 +Ref: table-gawk-rounding-modes966283 +Ref: Setting the rounding mode-Footnote-1970214 +Node: Arbitrary Precision Integers970393 +Ref: Arbitrary Precision Integers-Footnote-1973568 +Node: Checking for MPFR973717 +Node: POSIX Floating Point Problems975191 +Ref: POSIX Floating Point Problems-Footnote-1979476 +Node: Floating point summary979514 +Node: Dynamic Extensions981704 +Node: Extension Intro983257 +Node: Plugin License984523 +Node: Extension Mechanism Outline985320 +Ref: figure-load-extension985759 +Ref: figure-register-new-function987324 +Ref: figure-call-new-function988416 +Node: Extension API Description990478 +Node: Extension API Functions Introduction992120 +Ref: table-api-std-headers993956 +Node: General Data Types997821 +Ref: General Data Types-Footnote-11006182 +Node: Memory Allocation Functions1006481 +Ref: Memory Allocation Functions-Footnote-11010691 +Node: Constructor Functions1010790 +Node: Registration Functions1014376 +Node: Extension Functions1015061 +Node: Exit Callback Functions1020383 +Node: Extension Version String1021633 +Node: Input Parsers1022296 +Node: Output Wrappers1035017 +Node: Two-way processors1039529 +Node: Printing Messages1041794 +Ref: Printing Messages-Footnote-11042965 +Node: Updating ERRNO1043118 +Node: Requesting Values1043857 +Ref: table-value-types-returned1044594 +Node: Accessing Parameters1045530 +Node: Symbol Table Access1046765 +Node: Symbol table by name1047277 +Ref: Symbol table by name-Footnote-11050301 +Node: Symbol table by cookie1050429 +Ref: Symbol table by cookie-Footnote-11054614 +Node: Cached values1054678 +Ref: Cached values-Footnote-11058214 +Node: Array Manipulation1058367 +Ref: Array Manipulation-Footnote-11059458 +Node: Array Data Types1059495 +Ref: Array Data Types-Footnote-11062153 +Node: Array Functions1062245 +Node: Flattening Arrays1066743 +Node: Creating Arrays1073719 +Node: Redirection API1078486 +Node: Extension API Variables1081319 +Node: Extension Versioning1082030 +Ref: gawk-api-version1082459 +Node: Extension GMP/MPFR Versioning1084190 +Node: Extension API Informational Variables1085818 +Node: Extension API Boilerplate1086891 +Node: Changes from API V11090865 +Node: Finding Extensions1092437 +Node: Extension Example1092996 +Node: Internal File Description1093794 +Node: Internal File Ops1097874 +Ref: Internal File Ops-Footnote-11109224 +Node: Using Internal File Ops1109364 +Ref: Using Internal File Ops-Footnote-11111747 +Node: Extension Samples1112021 +Node: Extension Sample File Functions1113550 +Node: Extension Sample Fnmatch1121199 +Node: Extension Sample Fork1122686 +Node: Extension Sample Inplace1123904 +Node: Extension Sample Ord1127529 +Node: Extension Sample Readdir1128365 +Ref: table-readdir-file-types1129254 +Node: Extension Sample Revout1130321 +Node: Extension Sample Rev2way1130910 +Node: Extension Sample Read write array1131650 +Node: Extension Sample Readfile1133592 +Node: Extension Sample Time1134687 +Node: Extension Sample API Tests1136439 +Node: gawkextlib1136931 +Node: Extension summary1139849 +Node: Extension Exercises1143551 +Node: Language History1144793 +Node: V7/SVR3.11146449 +Node: SVR41148601 +Node: POSIX1150035 +Node: BTL1151415 +Node: POSIX/GNU1152144 +Node: Feature History1157922 +Node: Common Extensions1174115 +Node: Ranges and Locales1175398 +Ref: Ranges and Locales-Footnote-11180014 +Ref: Ranges and Locales-Footnote-21180041 +Ref: Ranges and Locales-Footnote-31180276 +Node: Contributors1180497 +Node: History summary1186450 +Node: Installation1187830 +Node: Gawk Distribution1188774 +Node: Getting1189258 +Node: Extracting1190221 +Node: Distribution contents1191859 +Node: Unix Installation1198339 +Node: Quick Installation1199021 +Node: Shell Startup Files1201435 +Node: Additional Configuration Options1202524 +Node: Configuration Philosophy1204839 +Node: Non-Unix Installation1207208 +Node: PC Installation1207668 +Node: PC Binary Installation1208506 +Node: PC Compiling1208941 +Node: PC Using1210058 +Node: Cygwin1213611 +Node: MSYS1214835 +Node: VMS Installation1215336 +Node: VMS Compilation1216127 +Ref: VMS Compilation-Footnote-11217356 +Node: VMS Dynamic Extensions1217414 +Node: VMS Installation Details1219099 +Node: VMS Running1221352 +Node: VMS GNV1225631 +Node: VMS Old Gawk1226366 +Node: Bugs1226837 +Node: Bug address1227500 +Node: Usenet1230482 +Node: Maintainers1231486 +Node: Other Versions1232747 +Node: Installation summary1239835 +Node: Notes1241037 +Node: Compatibility Mode1241831 +Node: Additions1242613 +Node: Accessing The Source1243538 +Node: Adding Code1244975 +Node: New Ports1251194 +Node: Derived Files1255569 +Ref: Derived Files-Footnote-11261229 +Ref: Derived Files-Footnote-21261264 +Ref: Derived Files-Footnote-31261862 +Node: Future Extensions1261976 +Node: Implementation Limitations1262634 +Node: Extension Design1263817 +Node: Old Extension Problems1264961 +Ref: Old Extension Problems-Footnote-11266479 +Node: Extension New Mechanism Goals1266536 +Ref: Extension New Mechanism Goals-Footnote-11269900 +Node: Extension Other Design Decisions1270089 +Node: Extension Future Growth1272202 +Node: Notes summary1273038 +Node: Basic Concepts1274196 +Node: Basic High Level1274877 +Ref: figure-general-flow1275159 +Ref: figure-process-flow1275844 +Ref: Basic High Level-Footnote-11279145 +Node: Basic Data Typing1279330 +Node: Glossary1282658 +Node: Copying1314496 +Node: GNU Free Documentation License1352039 +Node: Index1377159 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 9a62fb8d..51bb1d53 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -59,7 +59,7 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH September, 2019 +@set UPDATE-MONTH January, 2020 @set VERSION 5.1 @set PATCHLEVEL 0 @@ -285,13 +285,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2019 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2020 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2019 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2020 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -26987,6 +26987,26 @@ print data[lines[i]], lines[i] This works because @code{data[$0]} is incremented each time a line is seen. +@c rick@openfortress.nl, Tue, 24 Dec 2019 13:43:06 +0100 +Rick van Rein offers the following one-liner to do the same job of +removing duplicates from unsorted text: + +@example +awk '@{ if (! seen[$0]++) print @}' +@end example + +This can be simplified even further, at the risk of becoming +almost too obscure: + +@example +awk '! seen[$0]++' +@end example + +@noindent +This version uses the expression as a pattern, relying on +@command{awk}'s default action of printing the line when +the pattern is true. + @node Extract Program @subsection Extracting Programs from Texinfo Source Files diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 7e40bc5f..0046bf57 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -54,7 +54,7 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH September, 2019 +@set UPDATE-MONTH January, 2020 @set VERSION 5.1 @set PATCHLEVEL 0 @@ -280,13 +280,13 @@ Fax: +1-617-542-2652 Email: <email>gnu@@gnu.org</email> URL: <ulink url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout> -<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2019 +<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2020 Free Software Foundation, Inc. All Rights Reserved.</literallayout> @end docbook @ifnotdocbook -Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2019 @* +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2020 @* Free Software Foundation, Inc. @end ifnotdocbook @sp 2 @@ -25997,6 +25997,26 @@ print data[lines[i]], lines[i] This works because @code{data[$0]} is incremented each time a line is seen. +@c rick@openfortress.nl, Tue, 24 Dec 2019 13:43:06 +0100 +Rick van Rein offers the following one-liner to do the same job of +removing duplicates from unsorted text: + +@example +awk '@{ if (! seen[$0]++) print @}' +@end example + +This can be simplified even further, at the risk of becoming +almost too obscure: + +@example +awk '! seen[$0]++' +@end example + +@noindent +This version uses the expression as a pattern, relying on +@command{awk}'s default action of printing the line when +the pattern is true. + @node Extract Program @subsection Extracting Programs from Texinfo Source Files |