| 1 |
This is datamash.info, produced by makeinfo version 7.1.1 from |
| 2 |
datamash.texi. |
| 3 |
|
| 4 |
This manual is for GNU Datamash (version 1.9, 28 March 2025), which |
| 5 |
provides command-line computations on input files. |
| 6 |
|
| 7 |
Copyright © 2014-2021 Assaf Gordon. Copyright © 2022-2025 Timothy |
| 8 |
Rice. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this |
| 11 |
document under the terms of the GNU Free Documentation License, |
| 12 |
Version 1.3 or any later version published by the Free Software |
| 13 |
Foundation; with no Invariant Sections, no Front-Cover Texts, and |
| 14 |
no Back-Cover Texts. A copy of the license is included in the |
| 15 |
section entitled "GNU Free Documentation License". |
| 16 |
INFO-DIR-SECTION Basics |
| 17 |
START-INFO-DIR-ENTRY |
| 18 |
* Datamash: (datamash). datamash |
| 19 |
END-INFO-DIR-ENTRY |
| 20 |
|
| 21 |
|
| 22 |
File: datamash.info, Node: Top, Next: Overview, Up: (dir) |
| 23 |
|
| 24 |
Datamash |
| 25 |
******** |
| 26 |
|
| 27 |
This manual is for GNU Datamash (version 1.9, 28 March 2025), which |
| 28 |
provides command-line computations on input files. |
| 29 |
|
| 30 |
* Menu: |
| 31 |
|
| 32 |
* Overview:: General purpose and information. |
| 33 |
* Invoking datamash:: How to run ‘datamash’. |
| 34 |
* Available Operations:: Available operations in ‘datamash’. |
| 35 |
* Statistical Operations:: Statistical operations in ‘datamash’. |
| 36 |
* Usage Examples:: Usage Examples. |
| 37 |
* Reporting bugs:: Sending bug reports and feature suggestions. |
| 38 |
* GNU Free Documentation License:: Copying and sharing this documentation. |
| 39 |
* Concept index:: Index of concepts. |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
File: datamash.info, Node: Overview, Next: Invoking datamash, Prev: Top, Up: Top |
| 44 |
|
| 45 |
1 Overview |
| 46 |
********** |
| 47 |
|
| 48 |
The ‘datamash’ program (<https://www.gnu.org/software/datamash>) |
| 49 |
performs calculation (e.g. _sum,_, _count_, _min_, _max_, _skewness_, |
| 50 |
_standard deviation_) on input files. |
| 51 |
|
| 52 |
Example: sum up the values in the first column of the input: |
| 53 |
|
| 54 |
$ seq 10 | datamash sum 1 |
| 55 |
55 |
| 56 |
|
| 57 |
‘datamash’ can group input data and perform operations on each group. |
| 58 |
It can sort the file, and read header lines. |
| 59 |
|
| 60 |
Example: Given a file with three fields (name, subject, score), find |
| 61 |
the average score in each subject: |
| 62 |
|
| 63 |
$ cat scores.txt |
| 64 |
Name Subject Score |
| 65 |
Bryan Arts 68 |
| 66 |
Isaiah Arts 80 |
| 67 |
Gabriel Health-Medicine 100 |
| 68 |
Tysza Business 92 |
| 69 |
Zackery Engineering 54 |
| 70 |
... |
| 71 |
|
| 72 |
$ datamash --sort --headers --group 2 mean 3 sstdev 3 < scores.txt |
| 73 |
GroupBy(Subject) mean(Score) sstdev(Score) |
| 74 |
Arts 68.9474 10.4215 |
| 75 |
Business 87.3636 5.18214 |
| 76 |
Engineering 66.5385 19.8814 |
| 77 |
Health-Medicine 90.6154 9.22441 |
| 78 |
Life-Sciences 55.3333 20.606 |
| 79 |
Social-Sciences 60.2667 17.2273 |
| 80 |
|
| 81 |
‘datamash’ is designed for interactive exploration of textual data |
| 82 |
and for automating tasks in shell scripts. |
| 83 |
|
| 84 |
‘datamash’ has a rich set of statistical functions to quickly assess |
| 85 |
information in textual input files. An example of calculating basic |
| 86 |
statistic (mean, 1st quartile, median, 3rd quartile, IQR, |
| 87 |
sample-standard-deviation, and p-value of Jarque-Bera test for normal |
| 88 |
distribution: |
| 89 |
|
| 90 |
$ datamash -H mean 1 q1 1 median 1 q3 1 iqr 1 sstdev 1 jarque 1 < FILE |
| 91 |
mean(x) q1(x) median(x) q3(x) iqr(x) sstdev(x) jarque(x) |
| 92 |
45.32 23 37 61.5 38.5 30.4487 8.0113-09 |
| 93 |
|
| 94 |
|
| 95 |
File: datamash.info, Node: Invoking datamash, Next: Available Operations, Prev: Overview, Up: Top |
| 96 |
|
| 97 |
2 Invoking ‘datamash’ |
| 98 |
********************* |
| 99 |
|
| 100 |
The format for running the ‘datamash’ program is: |
| 101 |
|
| 102 |
datamash [OPTION]... OP1 COLUMN1 [OP2 COLUMN2 ...] |
| 103 |
|
| 104 |
Where OP1 is the operation to perform on the values in COLUMN1. |
| 105 |
‘datamash’ reads input from stdin and performs one or more operations on |
| 106 |
the input data. If ‘--group’ is used, each operation is performed on |
| 107 |
every group. If ‘--group’ is not used, each operation is performed on |
| 108 |
all the values in the input file. |
| 109 |
|
| 110 |
The ‘LC_NUMERIC’ locale specifies the decimal-point character and the |
| 111 |
thousands separator. |
| 112 |
|
| 113 |
‘datamash’ supports the following operations: |
| 114 |
|
| 115 |
Primary operations: |
| 116 |
‘groupby’, ‘crosstab’, ‘transpose’, ‘reverse’, ‘check’ |
| 117 |
|
| 118 |
Line-Filtering operations: |
| 119 |
‘rmdup’ |
| 120 |
|
| 121 |
Per-Line operations: |
| 122 |
‘base64’, ‘debase64’, ‘md5’, ‘sha1’, ‘sha224’, ‘sha256’, ‘sha384’, |
| 123 |
‘sha512’, ‘bin’, ‘strbin’, ‘round’, ‘floor’, ‘ceil’, ‘trunc’, |
| 124 |
‘frac’, ‘dirname’, ‘basename’, ‘extname’, ‘barename’, ‘getnum’, |
| 125 |
‘cut’, ‘echo’ |
| 126 |
|
| 127 |
Group-by Numeric operations: |
| 128 |
‘sum’, ‘min’, ‘max’, ‘absmin’, ‘absmax’, ‘range’ |
| 129 |
|
| 130 |
Group-by Textual/Numeric operations: |
| 131 |
‘count’, ‘first’, ‘last’, ‘rand’, ‘unique’, ‘uniq’, ‘collapse’, |
| 132 |
‘countunique’ |
| 133 |
|
| 134 |
Group-by Statistical operations: |
| 135 |
‘mean’, ‘geomean’, ‘harmmean’, ‘mode’, ‘median’, ‘q1’, ‘q3’, ‘iqr’, |
| 136 |
‘perc’, ‘antimode’, ‘pstdev’, ‘sstdev’, ‘pvar’, ‘svar’, ‘ms’, |
| 137 |
‘rms’, ‘mad’, ‘madraw’, ‘sskew’, ‘pskew’, ‘skurt’, ‘pkurt’, |
| 138 |
‘jarque’, ‘dpo’, ‘scov’, ‘pcov’, ‘spearson’, ‘ppearson’, ‘dotprod’ |
| 139 |
|
| 140 |
Grouping options: |
| 141 |
|
| 142 |
‘--skip-comments’ |
| 143 |
‘-C’ |
| 144 |
Skip comment lines (starting with '#' or ';' and optional |
| 145 |
whitespace). |
| 146 |
|
| 147 |
‘--full’ |
| 148 |
‘-f’ |
| 149 |
Print entire input line before op results (default: print only the |
| 150 |
grouped keys). While using this option with non-linewise |
| 151 |
operations was historically permitted, it never produced very |
| 152 |
sensible output. Such usage has been deprecated, and in a future |
| 153 |
release it will result in an error. |
| 154 |
|
| 155 |
‘--group=X[,Y,Z]’ |
| 156 |
‘-g X[,Y,Z]’ |
| 157 |
Group input via fields X[,Y,Z]. By default, fields are separated |
| 158 |
by TABs. Use ‘--field-separator’ to change the delimiter |
| 159 |
character. Input file must be sorted by the same fields X[,Y,Z]. |
| 160 |
Use ‘--sort’ to automatically sort the input. If ‘--group’ is not |
| 161 |
specified, each operation is performed in the entire input file. |
| 162 |
Ranges of field numbers like X-Z are also supported. |
| 163 |
|
| 164 |
‘--header-in’ |
| 165 |
Indicates the first input line is column headers, and should not be |
| 166 |
used for any calculations. |
| 167 |
|
| 168 |
‘--header-out’ |
| 169 |
Print column headers as first line. If the column header names are |
| 170 |
known (i.e. the input file had a header line, and the ‘command’ |
| 171 |
was invoked with ‘--header-in’, ‘-H’ or ‘--headers’), prints the |
| 172 |
operation and the name of the field (e.g. ‘mean(X)’). Otherwise, |
| 173 |
prints the number operation and the field number (e.g. |
| 174 |
‘mean(field-3)’). |
| 175 |
|
| 176 |
‘--headers’ |
| 177 |
‘-H’ |
| 178 |
Same as ‘--header-in --header-out’. A short option indicating the |
| 179 |
input file has a header line, and the output should contain a |
| 180 |
header line as well. |
| 181 |
|
| 182 |
‘--vnlog’ |
| 183 |
Enable experimental support for the vnlog data file format for both |
| 184 |
input and output. This format is explained at |
| 185 |
<https://github.com/dkogan/vnlog>. |
| 186 |
|
| 187 |
‘--ignore-case’ |
| 188 |
‘-i’ |
| 189 |
Ignore upper/lower case when comparing text for grouping, sorting, |
| 190 |
and comparing unique values in the ‘countunique’ and ‘unique’ (or |
| 191 |
‘uniq’) operations. |
| 192 |
|
| 193 |
‘--sort’ |
| 194 |
‘-s’ |
| 195 |
Sort the input before grouping. ‘datamash’ requires sorted input. |
| 196 |
If the input is not sorted, using ‘--sort’ will automatically sort |
| 197 |
the input before processing it further. Sorting will be performed |
| 198 |
based on the specified ‘--group’ parameter, and respecting case |
| 199 |
‘--ignore-case’ option (if used). The following commands are |
| 200 |
equivalent: |
| 201 |
$ cat FILE | sort -k1,1 | datamash --group 1 sum 1 |
| 202 |
$ cat FILE | datamash --sort --group 1 sum 1 |
| 203 |
|
| 204 |
‘--sort-cmd=PATH’ |
| 205 |
Use the given program to sort instead of the system ‘sort’ |
| 206 |
|
| 207 |
File Operation options: |
| 208 |
|
| 209 |
‘--no-strict’ |
| 210 |
Allow lines with varying number of fields. By default, ‘transpose’ |
| 211 |
and ‘reverse’ will fail with an error message unless all input |
| 212 |
lines have the same number of fields. |
| 213 |
|
| 214 |
‘--filler=X’ |
| 215 |
When use ‘--no-strict’ option, missing fields will be filled with |
| 216 |
this value. |
| 217 |
|
| 218 |
General options: |
| 219 |
|
| 220 |
‘--format=FORMAT’ |
| 221 |
print numeric values with printf style floating-point FORMAT. |
| 222 |
|
| 223 |
‘--field-separator=X’ |
| 224 |
‘-t X’ |
| 225 |
Use character X instead of TAB as input and output field delimiter. |
| 226 |
If ‘--output-delimiter’ is also used, it will override the output |
| 227 |
field delimiter. |
| 228 |
|
| 229 |
‘--narm’ |
| 230 |
Skip NA or NAN values. |
| 231 |
|
| 232 |
‘--output-delimiter=X’ |
| 233 |
Use character X instead as output field delimiter. This option |
| 234 |
overrides ‘--field-separator’/‘-t’/ ‘--whitespace’/‘-W’. |
| 235 |
|
| 236 |
‘--collapse-delimiter=X’ |
| 237 |
‘-c X’ |
| 238 |
|
| 239 |
Use character X instead of comma to delimit items in a ‘collapse’ |
| 240 |
or ‘unique’ (aka ‘uniq’) list. |
| 241 |
|
| 242 |
‘--round=N’ |
| 243 |
‘-R N’ |
| 244 |
Round numeric output to N decimal places. |
| 245 |
|
| 246 |
‘--whitespace’ |
| 247 |
‘-W’ |
| 248 |
Use whitespace (one or more spaces and/or tabs) for field |
| 249 |
delimiters. Leading whitespace is ignored, trailing whitespace |
| 250 |
results in an empty field. TAB character will be used as output |
| 251 |
field separator. If ‘--output-delimiter’ is also used, it will |
| 252 |
override the output field delimiter. |
| 253 |
|
| 254 |
‘--seed’ |
| 255 |
‘-S’ |
| 256 |
Select a specific random seed. By default, GNU Datamash uses |
| 257 |
getrandom(2), which should be suitable for most purposes. You may |
| 258 |
wish to force a specific seed if you either wish to draw on a |
| 259 |
specific entropy source or for ensuring the reproducibility of a |
| 260 |
specific test. |
| 261 |
|
| 262 |
‘--zero-terminated’ |
| 263 |
‘-z’ |
| 264 |
End lines with a 0 byte, not newline. |
| 265 |
|
| 266 |
‘--help’ |
| 267 |
‘-h’ |
| 268 |
Print an informative help message on standard output and exit |
| 269 |
successfully. |
| 270 |
|
| 271 |
‘--version’ |
| 272 |
‘-V’ |
| 273 |
Print the version number and licensing information of Datamash on |
| 274 |
standard output and then exit successfully. |
| 275 |
|
| 276 |
|
| 277 |
File: datamash.info, Node: Available Operations, Next: Statistical Operations, Prev: Invoking datamash, Up: Top |
| 278 |
|
| 279 |
3 Available operations in ‘datamash’ |
| 280 |
************************************ |
| 281 |
|
| 282 |
Primary operations: |
| 283 |
|
| 284 |
‘groupby’ |
| 285 |
alternative syntax for ‘--group’ |
| 286 |
‘crosstab’ |
| 287 |
cross-tabulate two fields (also known as 'pivot-tables') |
| 288 |
‘transpose’ |
| 289 |
transpose rows, columns of a text file |
| 290 |
‘reverse’ |
| 291 |
reverse fields in each line of a text file |
| 292 |
‘check’ |
| 293 |
verify tabular structure of input (ensure same number of |
| 294 |
fields in all lines) |
| 295 |
|
| 296 |
Line-Filtering operation: |
| 297 |
|
| 298 |
‘rmdup’ |
| 299 |
remove lines with duplicated key value |
| 300 |
|
| 301 |
Per-Line operations: |
| 302 |
|
| 303 |
‘base64’ |
| 304 |
encode the field as base64 |
| 305 |
‘debase64’ |
| 306 |
decode the field as base64. Exit with an error if the field |
| 307 |
is invalid base64 value which cannot be decoded. |
| 308 |
‘md5’ |
| 309 |
calculates md5 hash of the field |
| 310 |
‘sha1’ |
| 311 |
calculates sha1 hash of the field |
| 312 |
‘sha224’ |
| 313 |
calculates sha224 hash of the field |
| 314 |
‘sha256’ |
| 315 |
calculates sha256 hash of the field |
| 316 |
‘sha384’ |
| 317 |
calculates sha384 hash of the field |
| 318 |
‘sha512’ |
| 319 |
calculates sha512 hash of the field |
| 320 |
‘dirname’ |
| 321 |
extracts the directory name of the field (assuming the field |
| 322 |
is a file name). Similar to ‘dirname(1)’. |
| 323 |
‘basename’ |
| 324 |
extracts the base file name of the field (assuming the field |
| 325 |
is a file name). Similar to ‘basename(1)’. |
| 326 |
‘extname’ |
| 327 |
extracts the extension of the file name of the field (assuming |
| 328 |
the field is a file name). |
| 329 |
‘extname’ |
| 330 |
extracts the base file name of the field without the extension |
| 331 |
(assuming the field is a file name). |
| 332 |
‘getnum’ |
| 333 |
extract a number from the field. ‘getnum’ accepts an optional |
| 334 |
single letter option ‘n/i/d/p/h/o’ affecting the detected |
| 335 |
value. |
| 336 |
‘cut’ |
| 337 |
copy input field to output field (similar to ‘cut(1)’). When |
| 338 |
the ‘cut’ operation is given a list of fields, the fields are |
| 339 |
copied in the given order (in contrast to ‘cut(1)’). |
| 340 |
‘echo’ |
| 341 |
an alias for ‘cut’. |
| 342 |
|
| 343 |
Group-by Numeric operations: |
| 344 |
|
| 345 |
‘sum’ |
| 346 |
sum the of values |
| 347 |
‘min’ |
| 348 |
minimum value |
| 349 |
‘max’ |
| 350 |
maximum value |
| 351 |
‘absmin’ |
| 352 |
minimum of the absolute values |
| 353 |
‘absmax’ |
| 354 |
maximum of the absolute values |
| 355 |
‘range’ |
| 356 |
range of values (maximum - minimum) |
| 357 |
|
| 358 |
Group-By Textual/Numeric operations: |
| 359 |
|
| 360 |
‘count’ |
| 361 |
count number of elements in the group |
| 362 |
‘first’ |
| 363 |
the first value of the group |
| 364 |
‘last’ |
| 365 |
the last value of the group |
| 366 |
‘rand’ |
| 367 |
one random value from the group |
| 368 |
‘unique’ |
| 369 |
comma-separated sorted list of unique values |
| 370 |
‘uniq’ |
| 371 |
an alias for ‘unique’. |
| 372 |
|
| 373 |
‘--collapse-delimiter’ can be used to use a different |
| 374 |
character than comma. |
| 375 |
|
| 376 |
‘collapse’ |
| 377 |
comma-separated list of all input values |
| 378 |
|
| 379 |
‘--collapse-delimiter’ can be used to use a different |
| 380 |
character than comma. |
| 381 |
|
| 382 |
‘countunique’ |
| 383 |
number of unique/distinct values |
| 384 |
|
| 385 |
Group-By Statistical operations: |
| 386 |
|
| 387 |
‘mean’ |
| 388 |
mean of the values |
| 389 |
‘geomean’ |
| 390 |
geometric mean of the values |
| 391 |
‘harmmean’ |
| 392 |
harmonic mean of the values |
| 393 |
‘trimmean’ |
| 394 |
trimmed mean of the values |
| 395 |
‘ms’ |
| 396 |
mean square of the values |
| 397 |
‘rms’ |
| 398 |
root mean square of the values |
| 399 |
‘median’ |
| 400 |
median value |
| 401 |
‘q1’ |
| 402 |
1st quartile value |
| 403 |
‘q3’ |
| 404 |
3rd quartile value |
| 405 |
‘iqr’ |
| 406 |
inter-quartile range |
| 407 |
‘perc’ |
| 408 |
percentile value |
| 409 |
‘mode’ |
| 410 |
mode value (most common value) |
| 411 |
‘antimode’ |
| 412 |
anti-mode value (least common value) |
| 413 |
‘pstdev’ |
| 414 |
population standard deviation |
| 415 |
‘sstdev’ |
| 416 |
sample standard deviation |
| 417 |
‘pvar’ |
| 418 |
population variance |
| 419 |
‘svar’ |
| 420 |
sample variance |
| 421 |
‘mad’ |
| 422 |
Median Absolute Deviation, scaled by a constant 1.4826 for |
| 423 |
normal distributions |
| 424 |
‘madraw’ |
| 425 |
Median Absolute Deviation, unscaled |
| 426 |
‘sskew’ |
| 427 |
skewness of the (sample) group |
| 428 |
‘pskew’ |
| 429 |
skewness of the (population) group |
| 430 |
‘skurt’ |
| 431 |
Excess Kurtosis of the (sample) group |
| 432 |
‘pkurt’ |
| 433 |
Excess Kurtosis of the (population) group |
| 434 |
‘jarque’ |
| 435 |
p-value of the Jarque-Beta test for normality |
| 436 |
‘dpo’ |
| 437 |
p-value of the D'Agostino-Pearson Omnibus test for normality. |
| 438 |
|
| 439 |
|
| 440 |
File: datamash.info, Node: Statistical Operations, Next: Usage Examples, Prev: Available Operations, Up: Top |
| 441 |
|
| 442 |
4 Statistical Operations |
| 443 |
************************ |
| 444 |
|
| 445 |
Equivalent R functions |
| 446 |
====================== |
| 447 |
|
| 448 |
GNU Datamash is designed to closely follow R project's |
| 449 |
(<https://www.r-project.org/>) statistical functions. See the |
| 450 |
‘files/operators.R’ file for the R equivalent code for each of |
| 451 |
datamash's operators. When building ‘datamash’ from source code on your |
| 452 |
local computer, operators are compared to known results of the |
| 453 |
equivalent R functions. |
| 454 |
|
| 455 |
|
| 456 |
File: datamash.info, Node: Usage Examples, Next: Reporting bugs, Prev: Statistical Operations, Up: Top |
| 457 |
|
| 458 |
5 Usage Examples |
| 459 |
**************** |
| 460 |
|
| 461 |
* Menu: |
| 462 |
|
| 463 |
* Summary Statistics:: count,min,max,mean,stdev,median,quartiles |
| 464 |
* Header Lines and Column Names:: Using files with header lines |
| 465 |
* Field Delimiters:: Tabs, Whitespace, other delimiters |
| 466 |
* Column Ranges:: Operating on multiple columns |
| 467 |
* Reverse and Transpose:: swapping and transposing rows, columns |
| 468 |
* Groupby on /etc/passwd:: Groupby, count, collapse |
| 469 |
* Check:: Validate tabular structure |
| 470 |
* Crosstab:: Cross-tabulation (pivot-tables) |
| 471 |
* Rounding numbers:: round, ceil, floor, trunc, frac |
| 472 |
* Binning numbers:: assigning numbers into fixed number of buckets |
| 473 |
* Binning strings:: assigning strings into fixed number of buckets |
| 474 |
* Extracting numeric values:: using getnum |
| 475 |
|
| 476 |
|
| 477 |
File: datamash.info, Node: Summary Statistics, Next: Header Lines and Column Names, Up: Usage Examples |
| 478 |
|
| 479 |
5.1 Summary Statistics |
| 480 |
====================== |
| 481 |
|
| 482 |
The following are examples of using ‘datamash’ to quickly calculate |
| 483 |
summary statistics. The examples will use a file with three fields |
| 484 |
(name, subject, score) representing grades of students: |
| 485 |
|
| 486 |
$ cat scores.txt |
| 487 |
Shawn Arts 65 |
| 488 |
Marques Arts 58 |
| 489 |
Fernando Arts 78 |
| 490 |
Paul Arts 63 |
| 491 |
Walter Arts 75 |
| 492 |
... |
| 493 |
|
| 494 |
Counting how many students study each subject (_subject_ is the |
| 495 |
second field in the input file, thus ‘groupby 2’): |
| 496 |
|
| 497 |
$ datamash --sort groupby 2 count 2 < scores.txt |
| 498 |
Arts 19 |
| 499 |
Business 11 |
| 500 |
Engineering 13 |
| 501 |
Health-Medicine 13 |
| 502 |
Life-Sciences 12 |
| 503 |
Social-Sciences 15 |
| 504 |
|
| 505 |
Similarly, find the minimum and maximum score in each subject: |
| 506 |
|
| 507 |
$ datamash --sort groupby 2 min 3 max 3 < scores.txt |
| 508 |
Arts 46 88 |
| 509 |
Business 79 94 |
| 510 |
Engineering 39 99 |
| 511 |
Health-Medicine 72 100 |
| 512 |
Life-Sciences 14 91 |
| 513 |
Social-Sciences 27 90 |
| 514 |
|
| 515 |
find the mean and (population) standard deviation in each subject: |
| 516 |
|
| 517 |
$ datamash --sort groupby 2 mean 3 pstdev 3 < scores.txt |
| 518 |
Arts 68.947 10.143 |
| 519 |
Business 87.363 4.940 |
| 520 |
Engineering 66.538 19.101 |
| 521 |
Health-Medicine 90.615 8.862 |
| 522 |
Life-Sciences 55.333 19.728 |
| 523 |
Social-Sciences 60.266 16.643 |
| 524 |
|
| 525 |
Find the median, first, third quartiles and the inter-quartile range |
| 526 |
in each subject: |
| 527 |
|
| 528 |
$ datamash --sort groupby 2 median 3 q1 3 q3 3 iqr 3 < scores.txt |
| 529 |
Arts 71 61.5 75.5 14 |
| 530 |
Business 87 83 92 9 |
| 531 |
Engineering 56 51 83 32 |
| 532 |
Health-Medicine 91 84 100 16 |
| 533 |
Life-Sciences 58.5 44.25 67.75 23.5 |
| 534 |
Social-Sciences 62 55 70.5 15.5 |
| 535 |
|
| 536 |
*Note Header Lines and Column Names:: for examples of dealing with |
| 537 |
header lines. |
| 538 |
|
| 539 |
|
| 540 |
File: datamash.info, Node: Header Lines and Column Names, Next: Field Delimiters, Prev: Summary Statistics, Up: Usage Examples |
| 541 |
|
| 542 |
5.2 Header Lines and Column Names |
| 543 |
================================= |
| 544 |
|
| 545 |
Output Header Lines |
| 546 |
------------------- |
| 547 |
|
| 548 |
If the input does _not_ have a header line, use ‘--header-out’ to add a |
| 549 |
header in the first line of the output, indicating which operation was |
| 550 |
performed: |
| 551 |
|
| 552 |
$ datamash --sort --header-out groupby 2 min 3 max 3 < scores.txt |
| 553 |
GroupBy(field-2) min(field-3) max(field-3) |
| 554 |
Arts 46 88 |
| 555 |
Business 79 94 |
| 556 |
Engineering 39 99 |
| 557 |
Health-Medicine 72 100 |
| 558 |
Life-Sciences 14 91 |
| 559 |
Social-Sciences 27 90 |
| 560 |
|
| 561 |
Skipping Input Header Lines |
| 562 |
--------------------------- |
| 563 |
|
| 564 |
If the input has a header line (first line containing column names), use |
| 565 |
‘--header-in’ to skip the line: |
| 566 |
|
| 567 |
$ cat scores_h.txt |
| 568 |
Name Major Score |
| 569 |
Shawn Arts 65 |
| 570 |
Marques Arts 58 |
| 571 |
Fernando Arts 78 |
| 572 |
Paul Arts 63 |
| 573 |
... |
| 574 |
|
| 575 |
|
| 576 |
$ datamash --sort --header-in groupby 2 mean 3 < scores_h.txt |
| 577 |
Arts 68.947 |
| 578 |
Business 87.363 |
| 579 |
Engineering 66.538 |
| 580 |
Health-Medicine 90.615 |
| 581 |
Life-Sciences 55.333 |
| 582 |
Social-Sciences 60.266 |
| 583 |
|
| 584 |
If the header line is not skipped, ‘datamash’ will show an error (due |
| 585 |
to strict input validation): |
| 586 |
|
| 587 |
$ datamash groupby 2 mean 3 < scores_h.txt |
| 588 |
datamash: invalid numeric value in line 1 field 3: 'Score' |
| 589 |
|
| 590 |
Using Header Lines |
| 591 |
------------------ |
| 592 |
|
| 593 |
Column names in the input header lines can be printed in the output |
| 594 |
header lines by using ‘--headers’ (or ‘-H’, both are equivalent to |
| 595 |
‘--header-in --header-out’): |
| 596 |
|
| 597 |
$ datamash --sort --headers groupby 2 mean 3 < scores_h.txt |
| 598 |
GroupBy(Major) mean(Score) |
| 599 |
Arts 68.947 |
| 600 |
Business 87.363 |
| 601 |
Engineering 66.538 |
| 602 |
Health-Medicine 90.615 |
| 603 |
Life-Sciences 55.333 |
| 604 |
Social-Sciences 60.266 |
| 605 |
|
| 606 |
Or in short form (‘-sH’ instead of ‘--sort --headers’), equivalent to |
| 607 |
the above command: |
| 608 |
|
| 609 |
$ datamash -sH groupby 2 mean 3 |
| 610 |
|
| 611 |
Column Names |
| 612 |
------------ |
| 613 |
|
| 614 |
When the input file has a header line, column names can be used instead |
| 615 |
of column numbers. In the example below, MAJOR is used instead of the |
| 616 |
value 2, and SCORE is used instead of the value 3: |
| 617 |
|
| 618 |
$ datamash --sort --headers groupby Major mean Score < scores_h.txt |
| 619 |
GroupBy(Major) mean(Score) |
| 620 |
Arts 68.947 |
| 621 |
Business 87.363 |
| 622 |
Engineering 66.538 |
| 623 |
Health-Medicine 90.615 |
| 624 |
Life-Sciences 55.333 |
| 625 |
Social-Sciences 60.266 |
| 626 |
|
| 627 |
‘datamash’ will read the first line of the input, and deduce the |
| 628 |
correct column number based on the given name. If the column name is |
| 629 |
not found, an error will be printed: |
| 630 |
|
| 631 |
$ datamash --sort --headers groupby 2 mean Foo < scores_h.txt |
| 632 |
datamash: column name 'Foo' not found in input file |
| 633 |
|
| 634 |
Field names must be escaped with a backslash if they start with a |
| 635 |
digit or contain special characters (dash/minus, colons, commas). Note |
| 636 |
the interplay between escaping with backslash and shell quoting. The |
| 637 |
following equivalent command sum the values of a field named ‘FOO-BAR’: |
| 638 |
|
| 639 |
$ datamash -H sum FOO\\-BAR < input.txt |
| 640 |
$ datamash -H sum 'FOO\-BAR' < input.txt |
| 641 |
$ datamash -H sum "FOO\\-BAR" < input.txt |
| 642 |
|
| 643 |
|
| 644 |
File: datamash.info, Node: Field Delimiters, Next: Column Ranges, Prev: Header Lines and Column Names, Up: Usage Examples |
| 645 |
|
| 646 |
5.3 Field Delimiters |
| 647 |
==================== |
| 648 |
|
| 649 |
‘datamash’ uses tabs (ASCII character 0x09) as default field delimiters. |
| 650 |
Use ‘-W’ to treat one or more consecutive whitespace characters as field |
| 651 |
delimiters. Use ‘-t’, ‘--field-separator’ to set a custom field |
| 652 |
delimiter. |
| 653 |
|
| 654 |
The following examples illustrate the various options. |
| 655 |
|
| 656 |
By default, fields are separated by a single tab. Multiple tabs |
| 657 |
denotes multiple fields (this is consistent with GNU coreutils' ‘cut’): |
| 658 |
|
| 659 |
$ printf '1\t\t2\n' | datamash sum 3 |
| 660 |
2 |
| 661 |
$ printf '1\t\t2\n' | cut -f3 |
| 662 |
2 |
| 663 |
|
| 664 |
Every tab separates two fields. A line starting with a tab thus |
| 665 |
starts with an empty field, and a line ending with a tab ends with an |
| 666 |
empty field. |
| 667 |
|
| 668 |
Using ‘-W’, one or more consecutive whitespace characters are treated |
| 669 |
as a single field delimiter: |
| 670 |
|
| 671 |
$ printf '1 \t 2\n' | datamash -W sum 2 |
| 672 |
2 |
| 673 |
$ printf '1 \t 2\n' | datamash -W sum 3 |
| 674 |
datamash: invalid input: field 3 requested, line 1 has only 2 fields |
| 675 |
|
| 676 |
With ‘-W’, leading whitespace is ignored, but trailing whitespace is |
| 677 |
significant. A line starting with one or more consecutive whitespace |
| 678 |
characters followed by a non-whitespace character starts with a |
| 679 |
non-empty field. A line ending with one or more consecutive whitespace |
| 680 |
characters ends with an empty field. |
| 681 |
|
| 682 |
Using ‘-t’, a custom field delimiter character can be specified. |
| 683 |
Multiple consecutive delimiters are treated as multiple fields: |
| 684 |
|
| 685 |
$ printf '1,10,,100\n' | datamash -t, sum 4 |
| 686 |
100 |
| 687 |
|
| 688 |
|
| 689 |
File: datamash.info, Node: Column Ranges, Next: Reverse and Transpose, Prev: Field Delimiters, Up: Usage Examples |
| 690 |
|
| 691 |
5.4 Column Ranges |
| 692 |
================= |
| 693 |
|
| 694 |
‘datamash’ accepts column ranges such as 1,2,3 and 1-3. |
| 695 |
|
| 696 |
Simulating input with multiple columns: |
| 697 |
|
| 698 |
$ seq 100 | paste - - - - |
| 699 |
1 2 3 4 |
| 700 |
5 6 7 8 |
| 701 |
9 10 11 12 |
| 702 |
13 14 15 16 |
| 703 |
17 18 19 20 |
| 704 |
... |
| 705 |
|
| 706 |
The following are equivalent: |
| 707 |
|
| 708 |
$ seq 100 | paste - - - - | datamash sum 1 sum 2 sum 3 sum 4 |
| 709 |
1225 1250 1275 1300 |
| 710 |
|
| 711 |
$ seq 100 | paste - - - - | datamash sum 1,2,3,4 |
| 712 |
1225 1250 1275 1300 |
| 713 |
|
| 714 |
$ seq 100 | paste - - - - | datamash sum 1-4 |
| 715 |
1225 1250 1275 1300 |
| 716 |
|
| 717 |
$ seq 100 | paste - - - - | datamash sum 1-3,4 |
| 718 |
1225 1250 1275 1300 |
| 719 |
|
| 720 |
Ranges can be used with multiple operations: |
| 721 |
|
| 722 |
$ seq 100 | paste - - - - | datamash sum 1-4 mean 1-4 |
| 723 |
1225 1250 1275 1300 49 50 51 52 |
| 724 |
|
| 725 |
|
| 726 |
File: datamash.info, Node: Reverse and Transpose, Next: Groupby on /etc/passwd, Prev: Column Ranges, Up: Usage Examples |
| 727 |
|
| 728 |
5.5 Reverse and Transpose |
| 729 |
========================= |
| 730 |
|
| 731 |
Transpose |
| 732 |
--------- |
| 733 |
|
| 734 |
Use ‘transpose’ to swap rows and columns in a file: |
| 735 |
|
| 736 |
$ cat input.txt |
| 737 |
Sample Year Count |
| 738 |
A 2014 1002 |
| 739 |
B 2013 990 |
| 740 |
C 2014 2030 |
| 741 |
D 2014 599 |
| 742 |
|
| 743 |
$ datamash transpose < input.txt |
| 744 |
Sample A B C D |
| 745 |
Year 2014 2013 2014 2014 |
| 746 |
Count 1002 990 2030 599 |
| 747 |
|
| 748 |
By default, ‘transpose’ verifies the input has the same number of |
| 749 |
fields in each line, and fails with an error otherwise: |
| 750 |
|
| 751 |
$ cat input.txt |
| 752 |
Sample Year Count |
| 753 |
A 2014 1002 |
| 754 |
B 2013 |
| 755 |
C 2014 2030 |
| 756 |
D 2014 599 |
| 757 |
|
| 758 |
|
| 759 |
$ datamash transpose < input1.txt |
| 760 |
datamash: transpose input error: line 3 has 2 fields (previous lines had 3); |
| 761 |
see --help to disable strict mode |
| 762 |
|
| 763 |
Use ‘--no-strict’ to allow missing values: |
| 764 |
|
| 765 |
$ datamash --no-strict transpose < input1.txt |
| 766 |
Sample A B C D |
| 767 |
Year 2014 2013 2014 2014 |
| 768 |
Count 1002 N/A 2030 599 |
| 769 |
|
| 770 |
Use ‘--filler’ to set the missing-field filler value: |
| 771 |
|
| 772 |
$ datamash --no-strict --filler XYZ transpose < input1.txt |
| 773 |
Sample A B C D |
| 774 |
Year 2014 2013 2014 2014 |
| 775 |
Count 1002 XYZ 2030 599 |
| 776 |
|
| 777 |
Reverse |
| 778 |
------- |
| 779 |
|
| 780 |
Use ‘reverse’ to reverse the fields order in a file: |
| 781 |
|
| 782 |
$ cat input.txt |
| 783 |
Sample Year Count |
| 784 |
A 2014 1002 |
| 785 |
B 2013 990 |
| 786 |
C 2014 2030 |
| 787 |
D 2014 599 |
| 788 |
|
| 789 |
$ datamash reverse < input.txt |
| 790 |
Count Year Sample |
| 791 |
1002 2014 A |
| 792 |
990 2013 B |
| 793 |
2030 2014 C |
| 794 |
599 2014 D |
| 795 |
|
| 796 |
By default, reverse verifies the input has the same number of fields |
| 797 |
in each line, and fails with an error otherwise. Use ‘--no-strict’ to |
| 798 |
disable this behavior (see section above for an example). |
| 799 |
|
| 800 |
Combining Reverse and Transpose |
| 801 |
------------------------------- |
| 802 |
|
| 803 |
Reverse and Transpose can be combined to achieve various manipulations. |
| 804 |
(reminder: tac (https://www.gnu.org/software/coreutils/tac) can be used |
| 805 |
to reverse lines in a file): |
| 806 |
|
| 807 |
$ cat input.txt |
| 808 |
A 1 xx |
| 809 |
B 2 yy |
| 810 |
C 3 zz |
| 811 |
|
| 812 |
|
| 813 |
$ tac input.txt |
| 814 |
C 3 zz |
| 815 |
B 2 yy |
| 816 |
A 1 xx |
| 817 |
|
| 818 |
|
| 819 |
$ tac input.txt | datamash reverse |
| 820 |
zz 3 C |
| 821 |
yy 2 B |
| 822 |
xx 1 A |
| 823 |
|
| 824 |
|
| 825 |
$ cat input.txt | datamash reverse | datamash transpose |
| 826 |
xx yy zz |
| 827 |
1 2 3 |
| 828 |
A B C |
| 829 |
|
| 830 |
$ tac input.txt | datamash reverse | datamash transpose |
| 831 |
zz yy xx |
| 832 |
3 2 1 |
| 833 |
C B A |
| 834 |
|
| 835 |
|
| 836 |
File: datamash.info, Node: Groupby on /etc/passwd, Next: Check, Prev: Reverse and Transpose, Up: Usage Examples |
| 837 |
|
| 838 |
5.6 Groupby on ‘/etc/passwd’ |
| 839 |
============================ |
| 840 |
|
| 841 |
‘datamash’ with the ‘groupby’ operation mode can be used to aggregate |
| 842 |
information. |
| 843 |
|
| 844 |
Using this simulated ‘/etc/passwd’ file as input: |
| 845 |
|
| 846 |
$ cat passwd |
| 847 |
root:x:0:0:root:/root:/bin/bash |
| 848 |
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin |
| 849 |
bin:x:2:2:bin:/bin:/usr/sbin/nologin |
| 850 |
sys:x:3:3:sys:/dev:/usr/sbin/nologin |
| 851 |
sync:x:4:65534:sync:/bin:/bin/sync |
| 852 |
games:x:5:60:games:/usr/games:/usr/sbin/nologin |
| 853 |
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin |
| 854 |
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin |
| 855 |
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin |
| 856 |
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin |
| 857 |
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin |
| 858 |
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin |
| 859 |
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin |
| 860 |
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin |
| 861 |
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin |
| 862 |
mysql:x:115:124:MySQL Server,,,:/var/lib/mysql:/bin/false |
| 863 |
sshd:x:116:65534::/var/run/sshd:/usr/sbin/nologin |
| 864 |
guest:x:118:125:Guest,,,:/tmp/guest-home.phc17z:/bin/bash |
| 865 |
gordon:x:1004:1000:Assaf Gordon,,,,:/home/gordon:/bin/bash |
| 866 |
charles:x:1005:1000:Charles,,,,:/home/charles:/bin/bash |
| 867 |
alice:x:1006:1000:Alice,,,,:/home/alice:/bin/bash |
| 868 |
bob:x:1007:1000:Bob,,,,:/home/bob:/bin/bash |
| 869 |
postgres:x:119:126:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash |
| 870 |
rabbitmq:x:125:138:RabbitMQ messaging server,,,:/var/lib/rabbitmq:/bin/false |
| 871 |
redis:x:126:140:redis server,,,:/var/lib/redis:/bin/false |
| 872 |
postfix:x:127:141::/var/spool/postfix:/bin/false |
| 873 |
|
| 874 |
Parameter ‘-t’ is used to indicate the field separator : (instead of |
| 875 |
the default TAB). |
| 876 |
|
| 877 |
Aggregate (‘groupby’) login shells (column 7) and ‘count’ how many |
| 878 |
users use each: |
| 879 |
|
| 880 |
$ datamash -t: --sort groupby 7 count 7 < passwd |
| 881 |
/bin/bash:7 |
| 882 |
/bin/false:4 |
| 883 |
/bin/sync:1 |
| 884 |
/usr/sbin/nologin:14 |
| 885 |
|
| 886 |
Aggregate (‘groupby’) login shells (column 7) and print |
| 887 |
comma-separated list of users (column 1) for each shell (‘collapse’): |
| 888 |
|
| 889 |
$ cat passwd | datamash -t: --sort groupby 7 collapse 1 |
| 890 |
/bin/bash:root,guest,gordon,charles,alice,bob,postgres |
| 891 |
/bin/false:mysql,rabbitmq,redis,postfix |
| 892 |
/bin/sync:sync |
| 893 |
/usr/sbin/nologin:daemon,bin,sys,games,man,lp,mail,news,uucp,proxy ,www-data,backup,list,sshd |
| 894 |
|
| 895 |
Aggregate unix-groups (column 4) and print comma-separated list of |
| 896 |
users (column 1) for in each group: |
| 897 |
|
| 898 |
$ datamash -t: --sort groupby 4 collapse 1 < /etc/passwd |
| 899 |
0:root |
| 900 |
1:daemon |
| 901 |
10:uucp |
| 902 |
1000:gordon,charles,alice,bob |
| 903 |
12:man |
| 904 |
124:mysql |
| 905 |
125:guest |
| 906 |
126:postgres |
| 907 |
13:proxy |
| 908 |
138:rabbitmq |
| 909 |
140:redis |
| 910 |
141:postfix |
| 911 |
2:bin |
| 912 |
3:sys |
| 913 |
33:www-data |
| 914 |
34:backup |
| 915 |
38:list |
| 916 |
60:games |
| 917 |
65534:sync,sshd |
| 918 |
7:lp |
| 919 |
8:mail |
| 920 |
9:news |
| 921 |
|
| 922 |
|
| 923 |
File: datamash.info, Node: Check, Next: Crosstab, Prev: Groupby on /etc/passwd, Up: Usage Examples |
| 924 |
|
| 925 |
5.7 Check - checking tabular structure |
| 926 |
====================================== |
| 927 |
|
| 928 |
‘datamash’ ‘check’ validates the tabular structure of a file, ensuring |
| 929 |
all lines have the same number of fields. ‘check’ is meant to be used |
| 930 |
in scripting and automation pipelines, as it will terminate with |
| 931 |
non-zero exit code if the file is not well structured, while also |
| 932 |
printing detailed context information about the offending lines: |
| 933 |
|
| 934 |
$ cat good.txt |
| 935 |
A 1 ww |
| 936 |
B 2 xx |
| 937 |
C 3 yy |
| 938 |
D 4 zz |
| 939 |
|
| 940 |
|
| 941 |
$ cat bad.txt |
| 942 |
A 1 ww |
| 943 |
B 2 xx |
| 944 |
C 3 |
| 945 |
D 4 zz |
| 946 |
|
| 947 |
|
| 948 |
$ datamash check < good.txt && echo ok || echo fail |
| 949 |
4 lines, 3 fields |
| 950 |
ok |
| 951 |
|
| 952 |
|
| 953 |
$ datamash check < bad.txt && echo ok || echo fail |
| 954 |
line 2 (3 fields): |
| 955 |
B 2 xx |
| 956 |
line 3 (2 fields): |
| 957 |
C 3 |
| 958 |
datamash: check failed: line 3 has 2 fields (previous line had 3) |
| 959 |
fail |
| 960 |
|
| 961 |
5.7.1 Expected number of lines/fields |
| 962 |
------------------------------------- |
| 963 |
|
| 964 |
‘check’ accepts optional LINES and FIELDS and will return failure if the |
| 965 |
input does not have the requested number of lines/fields. |
| 966 |
|
| 967 |
The syntax is: |
| 968 |
|
| 969 |
datamash check [N lines] [N fields] |
| 970 |
|
| 971 |
Usage examples: |
| 972 |
|
| 973 |
$ cat file.txt |
| 974 |
A 1 ww |
| 975 |
B 2 xx |
| 976 |
C 3 yy |
| 977 |
D 4 zz |
| 978 |
|
| 979 |
$ datamash check 4 lines < file.txt && echo ok |
| 980 |
4 lines, 3 fields |
| 981 |
ok |
| 982 |
|
| 983 |
$ datamash check 3 fields < file.txt && echo ok |
| 984 |
4 lines, 3 fields |
| 985 |
ok |
| 986 |
|
| 987 |
$ datamash check 4 lines 3 fields < file.txt && echo ok |
| 988 |
4 lines, 3 fields |
| 989 |
ok |
| 990 |
|
| 991 |
$ datamash check 7 fields < file.txt && echo ok |
| 992 |
line 1 (3 fields): |
| 993 |
A 1 ww |
| 994 |
datamash: check failed: line 1 has 3 fields (expecting 22) |
| 995 |
|
| 996 |
$ datamash check 10 lines < file.txt && echo ok |
| 997 |
datamash: check failed: input had 4 lines (expecting 10) |
| 998 |
|
| 999 |
For convenience, LINE,ROW,ROWS can be used instead of LINES; |
| 1000 |
FIELD,COLUMNS,COLUMN,COL can be used instead of FIELDS. The following |
| 1001 |
are all equivalent: |
| 1002 |
|
| 1003 |
datamash check 4 lines 10 fields < file.txt |
| 1004 |
datamash check 4 rows 10 columns < file.txt |
| 1005 |
datamash check 10 col 4 row < file.txt |
| 1006 |
|
| 1007 |
5.7.2 checks in automation scripts |
| 1008 |
---------------------------------- |
| 1009 |
|
| 1010 |
In pipeline/automation context, it is often beneficial to validate files |
| 1011 |
as early as possible (immediately after file is created, as in fail-fast |
| 1012 |
methodology (https://en.wikipedia.org/wiki/Fail-fast)). A typical usage |
| 1013 |
in a shell script would be: |
| 1014 |
|
| 1015 |
#!/bin/sh |
| 1016 |
|
| 1017 |
die() |
| 1018 |
{ |
| 1019 |
base=$(basename "$0") |
| 1020 |
echo "$base: error: $@" >&2 |
| 1021 |
exit 1 |
| 1022 |
} |
| 1023 |
|
| 1024 |
custom pipeline-or-program > output.txt \ |
| 1025 |
|| die "program failed" |
| 1026 |
|
| 1027 |
datamash check < output.txt \ |
| 1028 |
|| die "'output.txt' has invalid structure (missing fields)" |
| 1029 |
|
| 1030 |
If the generated ‘output.txt’ file has invalid structure (i.e. |
| 1031 |
missing fields), ‘datamash’ will print the ‘stderr’ enough details to |
| 1032 |
help in troubleshooting (line numbers and offending line's content). |
| 1033 |
|
| 1034 |
|
| 1035 |
File: datamash.info, Node: Crosstab, Next: Rounding numbers, Prev: Check, Up: Usage Examples |
| 1036 |
|
| 1037 |
5.8 Crosstab - Cross-Tabulation (pivot-tables) |
| 1038 |
============================================== |
| 1039 |
|
| 1040 |
Cross-tabulation compares the relationship between two fields. Given |
| 1041 |
the following input file: |
| 1042 |
|
| 1043 |
$ cat input.txt |
| 1044 |
a x 3 |
| 1045 |
a y 7 |
| 1046 |
b x 21 |
| 1047 |
a x 40 |
| 1048 |
|
| 1049 |
Show cross-tabulation between the first field (a/b) and the second |
| 1050 |
field (x/y) - counting how many times each pair appears (note: sorting |
| 1051 |
is required): |
| 1052 |
|
| 1053 |
$ datamash -s crosstab 1,2 < input.txt |
| 1054 |
x y |
| 1055 |
a 2 1 |
| 1056 |
b 1 N/A |
| 1057 |
|
| 1058 |
The default operation is ‘count’ - in the above example, A and X |
| 1059 |
appear twice in the input file, while B and Y never appear together. |
| 1060 |
|
| 1061 |
An optional grouping operation can be used instead of counting. |
| 1062 |
|
| 1063 |
For each pair, ‘sum’ the values in the third column: |
| 1064 |
|
| 1065 |
$ datamash -s crosstab 1,2 sum 3 < input.txt |
| 1066 |
x y |
| 1067 |
a 43 7 |
| 1068 |
b 21 N/A |
| 1069 |
|
| 1070 |
For each pair, list all ‘unique’ values in the third column: |
| 1071 |
|
| 1072 |
$ datamash -s crosstab 1,2 unique 3 < input.txt |
| 1073 |
x y |
| 1074 |
a 3,40 7 |
| 1075 |
b 21 N/A |
| 1076 |
|
| 1077 |
Note that using ‘--header-out’ with crosstab prints a line showing |
| 1078 |
how to interpret the rows and columns, and what operation was used. |
| 1079 |
|
| 1080 |
$ datamash -s --header-in --header-out crosstab 1,2 < input.txt |
| 1081 |
GroupBy(a) GroupBy(x) count(a) |
| 1082 |
x y |
| 1083 |
a 1 1 |
| 1084 |
b 1 N/A |
| 1085 |
|
| 1086 |
|
| 1087 |
File: datamash.info, Node: Rounding numbers, Next: Binning numbers, Prev: Crosstab, Up: Usage Examples |
| 1088 |
|
| 1089 |
5.9 Rounding numbers |
| 1090 |
==================== |
| 1091 |
|
| 1092 |
The following demonstrate the different rounding operations: |
| 1093 |
|
| 1094 |
$ ( echo X ; seq -1.25 0.25 1.25 ) \ |
| 1095 |
| datamash --full -H round 1 ceil 1 floor 1 trunc 1 frac 1 |
| 1096 |
|
| 1097 |
X round(X) ceil(X) floor(X) trunc(X) frac(X) |
| 1098 |
-1.25 -1 -1 -2 -1 -0.25 |
| 1099 |
-1.00 -1 -1 -1 -1 0 |
| 1100 |
-0.75 -1 0 -1 0 -0.75 |
| 1101 |
-0.50 -1 0 -1 0 -0.5 |
| 1102 |
-0.25 0 0 -1 0 -0.25 |
| 1103 |
0.00 0 0 0 0 0 |
| 1104 |
0.25 0 1 0 0 0.25 |
| 1105 |
0.50 1 1 0 0 0.5 |
| 1106 |
0.75 1 1 0 0 0.75 |
| 1107 |
1.00 1 1 1 1 0 |
| 1108 |
1.25 1 2 1 1 0.25 |
| 1109 |
|
| 1110 |
|
| 1111 |
File: datamash.info, Node: Binning numbers, Next: Binning strings, Prev: Rounding numbers, Up: Usage Examples |
| 1112 |
|
| 1113 |
5.10 Binning numbers |
| 1114 |
==================== |
| 1115 |
|
| 1116 |
Bin input values into buckets of size 5: |
| 1117 |
|
| 1118 |
$ ( echo X ; seq -10 2.5 10 ) \ |
| 1119 |
| datamash -H --full bin:5 1 |
| 1120 |
X bin(X) |
| 1121 |
-10.0 -10 |
| 1122 |
-7.5 -10 |
| 1123 |
-5.0 -5 |
| 1124 |
-2.5 -5 |
| 1125 |
0.0 0 |
| 1126 |
2.5 0 |
| 1127 |
5.0 5 |
| 1128 |
7.5 5 |
| 1129 |
10.0 10 |
| 1130 |
|
| 1131 |
|
| 1132 |
File: datamash.info, Node: Binning strings, Next: Extracting numeric values, Prev: Binning numbers, Up: Usage Examples |
| 1133 |
|
| 1134 |
5.11 Binning strings |
| 1135 |
==================== |
| 1136 |
|
| 1137 |
Hash any string input value into a numeric integer. A typical usage |
| 1138 |
would be to split an input file into N chunks, ensuring that all values |
| 1139 |
of a certain key will be stored in the same chunk: |
| 1140 |
|
| 1141 |
$ cat input.txt |
| 1142 |
PatientA 10 |
| 1143 |
PatientB 11 |
| 1144 |
PatientC 12 |
| 1145 |
PatientA 14 |
| 1146 |
PatientC 15 |
| 1147 |
|
| 1148 |
Each patient ID is hashed into a bin between 0 and 9 and printed in |
| 1149 |
the last field: |
| 1150 |
|
| 1151 |
$ datamash --full strbin 1 < input.txt |
| 1152 |
PatientA 10 5 |
| 1153 |
PatientB 11 6 |
| 1154 |
PatientC 12 7 |
| 1155 |
PatientA 14 5 |
| 1156 |
PatientC 15 7 |
| 1157 |
|
| 1158 |
Splitting the input into chunks can be done with awk: |
| 1159 |
|
| 1160 |
$ cat input.txt | datamash --full strbin 1 \ |
| 1161 |
| awk '{print > $NF ".txt"}' |
| 1162 |
|
| 1163 |
|
| 1164 |
File: datamash.info, Node: Extracting numeric values, Prev: Binning strings, Up: Usage Examples |
| 1165 |
|
| 1166 |
5.12 Extracting numeric values - using getnum |
| 1167 |
============================================= |
| 1168 |
|
| 1169 |
The ‘getnum’ operation extracts a numeric value from the field: |
| 1170 |
|
| 1171 |
$ echo zoom-123.45xyz | datamash getnum 1 |
| 1172 |
123.45 |
| 1173 |
|
| 1174 |
‘getnum’ accepts an optional single-letter TYPE option: |
| 1175 |
|
| 1176 |
‘getnum:n’ |
| 1177 |
natural numbers (positive integers, including zero) |
| 1178 |
‘getnum:i’ |
| 1179 |
integers |
| 1180 |
‘getnum:d’ |
| 1181 |
decimal point numbers |
| 1182 |
‘getnum:p’ |
| 1183 |
positive decimal point numbers (this is the default) |
| 1184 |
‘getnum:h’ |
| 1185 |
hex numbers |
| 1186 |
‘getnum:o’ |
| 1187 |
octal numbers |
| 1188 |
|
| 1189 |
Examples: |
| 1190 |
|
| 1191 |
$ echo zoom-123.45xyz | datamash getnum 1 |
| 1192 |
123.45 |
| 1193 |
|
| 1194 |
$ echo zoom-123.45xyz | datamash getnum:n 1 |
| 1195 |
123 |
| 1196 |
|
| 1197 |
$ echo zoom-123.45xyz | datamash getnum:i 1 |
| 1198 |
-123 |
| 1199 |
|
| 1200 |
$ echo zoom-123.45xyz | datamash getnum:d 1 |
| 1201 |
123.45 |
| 1202 |
|
| 1203 |
$ echo zoom-123.45xyz | datamash getnum:p 1 |
| 1204 |
-123.45 |
| 1205 |
|
| 1206 |
# Hex 0x123 = 291 Decimal |
| 1207 |
$ echo zoom-123.45xyz | datamash getnum:h 1 |
| 1208 |
291 |
| 1209 |
|
| 1210 |
# Octal 0123 = 83 Decimal |
| 1211 |
$ echo zoom-123.45xyz | datamash getnum:o 1 |
| 1212 |
83 |
| 1213 |
|
| 1214 |
|
| 1215 |
File: datamash.info, Node: Reporting bugs, Next: GNU Free Documentation License, Prev: Usage Examples, Up: Top |
| 1216 |
|
| 1217 |
6 Reporting bugs |
| 1218 |
**************** |
| 1219 |
|
| 1220 |
To report bugs, suggest enhancements or otherwise discuss GNU Datamash, |
| 1221 |
please send electronic mail to <[email protected]>. |
| 1222 |
|
| 1223 |
For bug reports, please include enough information for the |
| 1224 |
maintainers to reproduce the problem. Generally speaking, that means: |
| 1225 |
|
| 1226 |
• The version numbers of Datamash (which you can find by running |
| 1227 |
‘datamash --version’) and any other program(s) or manual(s) |
| 1228 |
involved. |
| 1229 |
• Hardware and operating system names and versions. |
| 1230 |
• The contents of any input files necessary to reproduce the bug. |
| 1231 |
• The expected behavior and/or output. |
| 1232 |
• A description of the problem and samples of any erroneous output. |
| 1233 |
• Options you gave to ‘configure’ other than specifying installation |
| 1234 |
directories. |
| 1235 |
• Anything else that you think would be helpful. |
| 1236 |
|
| 1237 |
When in doubt whether something is needed or not, include it. It's |
| 1238 |
better to include too much than to leave out something important. |
| 1239 |
|
| 1240 |
Patches are welcome; if possible, please make them with ‘diff -u’ |
| 1241 |
(*note Overview: (diff)Top.) and include ‘ChangeLog’ entries (*note |
| 1242 |
(emacs)Change Log::). Please follow the existing coding style. |
| 1243 |
|
| 1244 |
|
| 1245 |
File: datamash.info, Node: GNU Free Documentation License, Next: Concept index, Prev: Reporting bugs, Up: Top |
| 1246 |
|
| 1247 |
Appendix A GNU Free Documentation License |
| 1248 |
***************************************** |
| 1249 |
|
| 1250 |
Version 1.3, 3 November 2008 |
| 1251 |
|
| 1252 |
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. |
| 1253 |
<https://fsf.org/> |
| 1254 |
|
| 1255 |
Everyone is permitted to copy and distribute verbatim copies |
| 1256 |
of this license document, but changing it is not allowed. |
| 1257 |
|
| 1258 |
0. PREAMBLE |
| 1259 |
|
| 1260 |
The purpose of this License is to make a manual, textbook, or other |
| 1261 |
functional and useful document “free” in the sense of freedom: to |
| 1262 |
assure everyone the effective freedom to copy and redistribute it, |
| 1263 |
with or without modifying it, either commercially or |
| 1264 |
noncommercially. Secondarily, this License preserves for the |
| 1265 |
author and publisher a way to get credit for their work, while not |
| 1266 |
being considered responsible for modifications made by others. |
| 1267 |
|
| 1268 |
This License is a kind of "copyleft", which means that derivative |
| 1269 |
works of the document must themselves be free in the same sense. |
| 1270 |
It complements the GNU General Public License, which is a copyleft |
| 1271 |
license designed for free software. |
| 1272 |
|
| 1273 |
We have designed this License in order to use it for manuals for |
| 1274 |
free software, because free software needs free documentation: a |
| 1275 |
free program should come with manuals providing the same freedoms |
| 1276 |
that the software does. But this License is not limited to |
| 1277 |
software manuals; it can be used for any textual work, regardless |
| 1278 |
of subject matter or whether it is published as a printed book. We |
| 1279 |
recommend this License principally for works whose purpose is |
| 1280 |
instruction or reference. |
| 1281 |
|
| 1282 |
1. APPLICABILITY AND DEFINITIONS |
| 1283 |
|
| 1284 |
This License applies to any manual or other work, in any medium, |
| 1285 |
that contains a notice placed by the copyright holder saying it can |
| 1286 |
be distributed under the terms of this License. Such a notice |
| 1287 |
grants a world-wide, royalty-free license, unlimited in duration, |
| 1288 |
to use that work under the conditions stated herein. The |
| 1289 |
"Document", below, refers to any such manual or work. Any member |
| 1290 |
of the public is a licensee, and is addressed as "you". You accept |
| 1291 |
the license if you copy, modify or distribute the work in a way |
| 1292 |
requiring permission under copyright law. |
| 1293 |
|
| 1294 |
A "Modified Version" of the Document means any work containing the |
| 1295 |
Document or a portion of it, either copied verbatim, or with |
| 1296 |
modifications and/or translated into another language. |
| 1297 |
|
| 1298 |
A "Secondary Section" is a named appendix or a front-matter section |
| 1299 |
of the Document that deals exclusively with the relationship of the |
| 1300 |
publishers or authors of the Document to the Document's overall |
| 1301 |
subject (or to related matters) and contains nothing that could |
| 1302 |
fall directly within that overall subject. (Thus, if the Document |
| 1303 |
is in part a textbook of mathematics, a Secondary Section may not |
| 1304 |
explain any mathematics.) The relationship could be a matter of |
| 1305 |
historical connection with the subject or with related matters, or |
| 1306 |
of legal, commercial, philosophical, ethical or political position |
| 1307 |
regarding them. |
| 1308 |
|
| 1309 |
The "Invariant Sections" are certain Secondary Sections whose |
| 1310 |
titles are designated, as being those of Invariant Sections, in the |
| 1311 |
notice that says that the Document is released under this License. |
| 1312 |
If a section does not fit the above definition of Secondary then it |
| 1313 |
is not allowed to be designated as Invariant. The Document may |
| 1314 |
contain zero Invariant Sections. If the Document does not identify |
| 1315 |
any Invariant Sections then there are none. |
| 1316 |
|
| 1317 |
The "Cover Texts" are certain short passages of text that are |
| 1318 |
listed, as Front-Cover Texts or Back-Cover Texts, in the notice |
| 1319 |
that says that the Document is released under this License. A |
| 1320 |
Front-Cover Text may be at most 5 words, and a Back-Cover Text may |
| 1321 |
be at most 25 words. |
| 1322 |
|
| 1323 |
A "Transparent" copy of the Document means a machine-readable copy, |
| 1324 |
represented in a format whose specification is available to the |
| 1325 |
general public, that is suitable for revising the document |
| 1326 |
straightforwardly with generic text editors or (for images composed |
| 1327 |
of pixels) generic paint programs or (for drawings) some widely |
| 1328 |
available drawing editor, and that is suitable for input to text |
| 1329 |
formatters or for automatic translation to a variety of formats |
| 1330 |
suitable for input to text formatters. A copy made in an otherwise |
| 1331 |
Transparent file format whose markup, or absence of markup, has |
| 1332 |
been arranged to thwart or discourage subsequent modification by |
| 1333 |
readers is not Transparent. An image format is not Transparent if |
| 1334 |
used for any substantial amount of text. A copy that is not |
| 1335 |
"Transparent" is called "Opaque". |
| 1336 |
|
| 1337 |
Examples of suitable formats for Transparent copies include plain |
| 1338 |
ASCII without markup, Texinfo input format, LaTeX input format, |
| 1339 |
SGML or XML using a publicly available DTD, and standard-conforming |
| 1340 |
simple HTML, PostScript or PDF designed for human modification. |
| 1341 |
Examples of transparent image formats include PNG, XCF and JPG. |
| 1342 |
Opaque formats include proprietary formats that can be read and |
| 1343 |
edited only by proprietary word processors, SGML or XML for which |
| 1344 |
the DTD and/or processing tools are not generally available, and |
| 1345 |
the machine-generated HTML, PostScript or PDF produced by some word |
| 1346 |
processors for output purposes only. |
| 1347 |
|
| 1348 |
The "Title Page" means, for a printed book, the title page itself, |
| 1349 |
plus such following pages as are needed to hold, legibly, the |
| 1350 |
material this License requires to appear in the title page. For |
| 1351 |
works in formats which do not have any title page as such, "Title |
| 1352 |
Page" means the text near the most prominent appearance of the |
| 1353 |
work's title, preceding the beginning of the body of the text. |
| 1354 |
|
| 1355 |
The "publisher" means any person or entity that distributes copies |
| 1356 |
of the Document to the public. |
| 1357 |
|
| 1358 |
A section "Entitled XYZ" means a named subunit of the Document |
| 1359 |
whose title either is precisely XYZ or contains XYZ in parentheses |
| 1360 |
following text that translates XYZ in another language. (Here XYZ |
| 1361 |
stands for a specific section name mentioned below, such as |
| 1362 |
"Acknowledgements", "Dedications", "Endorsements", or "History".) |
| 1363 |
To "Preserve the Title" of such a section when you modify the |
| 1364 |
Document means that it remains a section "Entitled XYZ" according |
| 1365 |
to this definition. |
| 1366 |
|
| 1367 |
The Document may include Warranty Disclaimers next to the notice |
| 1368 |
which states that this License applies to the Document. These |
| 1369 |
Warranty Disclaimers are considered to be included by reference in |
| 1370 |
this License, but only as regards disclaiming warranties: any other |
| 1371 |
implication that these Warranty Disclaimers may have is void and |
| 1372 |
has no effect on the meaning of this License. |
| 1373 |
|
| 1374 |
2. VERBATIM COPYING |
| 1375 |
|
| 1376 |
You may copy and distribute the Document in any medium, either |
| 1377 |
commercially or noncommercially, provided that this License, the |
| 1378 |
copyright notices, and the license notice saying this License |
| 1379 |
applies to the Document are reproduced in all copies, and that you |
| 1380 |
add no other conditions whatsoever to those of this License. You |
| 1381 |
may not use technical measures to obstruct or control the reading |
| 1382 |
or further copying of the copies you make or distribute. However, |
| 1383 |
you may accept compensation in exchange for copies. If you |
| 1384 |
distribute a large enough number of copies you must also follow the |
| 1385 |
conditions in section 3. |
| 1386 |
|
| 1387 |
You may also lend copies, under the same conditions stated above, |
| 1388 |
and you may publicly display copies. |
| 1389 |
|
| 1390 |
3. COPYING IN QUANTITY |
| 1391 |
|
| 1392 |
If you publish printed copies (or copies in media that commonly |
| 1393 |
have printed covers) of the Document, numbering more than 100, and |
| 1394 |
the Document's license notice requires Cover Texts, you must |
| 1395 |
enclose the copies in covers that carry, clearly and legibly, all |
| 1396 |
these Cover Texts: Front-Cover Texts on the front cover, and |
| 1397 |
Back-Cover Texts on the back cover. Both covers must also clearly |
| 1398 |
and legibly identify you as the publisher of these copies. The |
| 1399 |
front cover must present the full title with all words of the title |
| 1400 |
equally prominent and visible. You may add other material on the |
| 1401 |
covers in addition. Copying with changes limited to the covers, as |
| 1402 |
long as they preserve the title of the Document and satisfy these |
| 1403 |
conditions, can be treated as verbatim copying in other respects. |
| 1404 |
|
| 1405 |
If the required texts for either cover are too voluminous to fit |
| 1406 |
legibly, you should put the first ones listed (as many as fit |
| 1407 |
reasonably) on the actual cover, and continue the rest onto |
| 1408 |
adjacent pages. |
| 1409 |
|
| 1410 |
If you publish or distribute Opaque copies of the Document |
| 1411 |
numbering more than 100, you must either include a machine-readable |
| 1412 |
Transparent copy along with each Opaque copy, or state in or with |
| 1413 |
each Opaque copy a computer-network location from which the general |
| 1414 |
network-using public has access to download using public-standard |
| 1415 |
network protocols a complete Transparent copy of the Document, free |
| 1416 |
of added material. If you use the latter option, you must take |
| 1417 |
reasonably prudent steps, when you begin distribution of Opaque |
| 1418 |
copies in quantity, to ensure that this Transparent copy will |
| 1419 |
remain thus accessible at the stated location until at least one |
| 1420 |
year after the last time you distribute an Opaque copy (directly or |
| 1421 |
through your agents or retailers) of that edition to the public. |
| 1422 |
|
| 1423 |
It is requested, but not required, that you contact the authors of |
| 1424 |
the Document well before redistributing any large number of copies, |
| 1425 |
to give them a chance to provide you with an updated version of the |
| 1426 |
Document. |
| 1427 |
|
| 1428 |
4. MODIFICATIONS |
| 1429 |
|
| 1430 |
You may copy and distribute a Modified Version of the Document |
| 1431 |
under the conditions of sections 2 and 3 above, provided that you |
| 1432 |
release the Modified Version under precisely this License, with the |
| 1433 |
Modified Version filling the role of the Document, thus licensing |
| 1434 |
distribution and modification of the Modified Version to whoever |
| 1435 |
possesses a copy of it. In addition, you must do these things in |
| 1436 |
the Modified Version: |
| 1437 |
|
| 1438 |
A. Use in the Title Page (and on the covers, if any) a title |
| 1439 |
distinct from that of the Document, and from those of previous |
| 1440 |
versions (which should, if there were any, be listed in the |
| 1441 |
History section of the Document). You may use the same title |
| 1442 |
as a previous version if the original publisher of that |
| 1443 |
version gives permission. |
| 1444 |
|
| 1445 |
B. List on the Title Page, as authors, one or more persons or |
| 1446 |
entities responsible for authorship of the modifications in |
| 1447 |
the Modified Version, together with at least five of the |
| 1448 |
principal authors of the Document (all of its principal |
| 1449 |
authors, if it has fewer than five), unless they release you |
| 1450 |
from this requirement. |
| 1451 |
|
| 1452 |
C. State on the Title page the name of the publisher of the |
| 1453 |
Modified Version, as the publisher. |
| 1454 |
|
| 1455 |
D. Preserve all the copyright notices of the Document. |
| 1456 |
|
| 1457 |
E. Add an appropriate copyright notice for your modifications |
| 1458 |
adjacent to the other copyright notices. |
| 1459 |
|
| 1460 |
F. Include, immediately after the copyright notices, a license |
| 1461 |
notice giving the public permission to use the Modified |
| 1462 |
Version under the terms of this License, in the form shown in |
| 1463 |
the Addendum below. |
| 1464 |
|
| 1465 |
G. Preserve in that license notice the full lists of Invariant |
| 1466 |
Sections and required Cover Texts given in the Document's |
| 1467 |
license notice. |
| 1468 |
|
| 1469 |
H. Include an unaltered copy of this License. |
| 1470 |
|
| 1471 |
I. Preserve the section Entitled "History", Preserve its Title, |
| 1472 |
and add to it an item stating at least the title, year, new |
| 1473 |
authors, and publisher of the Modified Version as given on the |
| 1474 |
Title Page. If there is no section Entitled "History" in the |
| 1475 |
Document, create one stating the title, year, authors, and |
| 1476 |
publisher of the Document as given on its Title Page, then add |
| 1477 |
an item describing the Modified Version as stated in the |
| 1478 |
previous sentence. |
| 1479 |
|
| 1480 |
J. Preserve the network location, if any, given in the Document |
| 1481 |
for public access to a Transparent copy of the Document, and |
| 1482 |
likewise the network locations given in the Document for |
| 1483 |
previous versions it was based on. These may be placed in the |
| 1484 |
"History" section. You may omit a network location for a work |
| 1485 |
that was published at least four years before the Document |
| 1486 |
itself, or if the original publisher of the version it refers |
| 1487 |
to gives permission. |
| 1488 |
|
| 1489 |
K. For any section Entitled "Acknowledgements" or "Dedications", |
| 1490 |
Preserve the Title of the section, and preserve in the section |
| 1491 |
all the substance and tone of each of the contributor |
| 1492 |
acknowledgements and/or dedications given therein. |
| 1493 |
|
| 1494 |
L. Preserve all the Invariant Sections of the Document, unaltered |
| 1495 |
in their text and in their titles. Section numbers or the |
| 1496 |
equivalent are not considered part of the section titles. |
| 1497 |
|
| 1498 |
M. Delete any section Entitled "Endorsements". Such a section |
| 1499 |
may not be included in the Modified Version. |
| 1500 |
|
| 1501 |
N. Do not retitle any existing section to be Entitled |
| 1502 |
"Endorsements" or to conflict in title with any Invariant |
| 1503 |
Section. |
| 1504 |
|
| 1505 |
O. Preserve any Warranty Disclaimers. |
| 1506 |
|
| 1507 |
If the Modified Version includes new front-matter sections or |
| 1508 |
appendices that qualify as Secondary Sections and contain no |
| 1509 |
material copied from the Document, you may at your option designate |
| 1510 |
some or all of these sections as invariant. To do this, add their |
| 1511 |
titles to the list of Invariant Sections in the Modified Version's |
| 1512 |
license notice. These titles must be distinct from any other |
| 1513 |
section titles. |
| 1514 |
|
| 1515 |
You may add a section Entitled "Endorsements", provided it contains |
| 1516 |
nothing but endorsements of your Modified Version by various |
| 1517 |
parties--for example, statements of peer review or that the text |
| 1518 |
has been approved by an organization as the authoritative |
| 1519 |
definition of a standard. |
| 1520 |
|
| 1521 |
You may add a passage of up to five words as a Front-Cover Text, |
| 1522 |
and a passage of up to 25 words as a Back-Cover Text, to the end of |
| 1523 |
the list of Cover Texts in the Modified Version. Only one passage |
| 1524 |
of Front-Cover Text and one of Back-Cover Text may be added by (or |
| 1525 |
through arrangements made by) any one entity. If the Document |
| 1526 |
already includes a cover text for the same cover, previously added |
| 1527 |
by you or by arrangement made by the same entity you are acting on |
| 1528 |
behalf of, you may not add another; but you may replace the old |
| 1529 |
one, on explicit permission from the previous publisher that added |
| 1530 |
the old one. |
| 1531 |
|
| 1532 |
The author(s) and publisher(s) of the Document do not by this |
| 1533 |
License give permission to use their names for publicity for or to |
| 1534 |
assert or imply endorsement of any Modified Version. |
| 1535 |
|
| 1536 |
5. COMBINING DOCUMENTS |
| 1537 |
|
| 1538 |
You may combine the Document with other documents released under |
| 1539 |
this License, under the terms defined in section 4 above for |
| 1540 |
modified versions, provided that you include in the combination all |
| 1541 |
of the Invariant Sections of all of the original documents, |
| 1542 |
unmodified, and list them all as Invariant Sections of your |
| 1543 |
combined work in its license notice, and that you preserve all |
| 1544 |
their Warranty Disclaimers. |
| 1545 |
|
| 1546 |
The combined work need only contain one copy of this License, and |
| 1547 |
multiple identical Invariant Sections may be replaced with a single |
| 1548 |
copy. If there are multiple Invariant Sections with the same name |
| 1549 |
but different contents, make the title of each such section unique |
| 1550 |
by adding at the end of it, in parentheses, the name of the |
| 1551 |
original author or publisher of that section if known, or else a |
| 1552 |
unique number. Make the same adjustment to the section titles in |
| 1553 |
the list of Invariant Sections in the license notice of the |
| 1554 |
combined work. |
| 1555 |
|
| 1556 |
In the combination, you must combine any sections Entitled |
| 1557 |
"History" in the various original documents, forming one section |
| 1558 |
Entitled "History"; likewise combine any sections Entitled |
| 1559 |
"Acknowledgements", and any sections Entitled "Dedications". You |
| 1560 |
must delete all sections Entitled "Endorsements." |
| 1561 |
|
| 1562 |
6. COLLECTIONS OF DOCUMENTS |
| 1563 |
|
| 1564 |
You may make a collection consisting of the Document and other |
| 1565 |
documents released under this License, and replace the individual |
| 1566 |
copies of this License in the various documents with a single copy |
| 1567 |
that is included in the collection, provided that you follow the |
| 1568 |
rules of this License for verbatim copying of each of the documents |
| 1569 |
in all other respects. |
| 1570 |
|
| 1571 |
You may extract a single document from such a collection, and |
| 1572 |
distribute it individually under this License, provided you insert |
| 1573 |
a copy of this License into the extracted document, and follow this |
| 1574 |
License in all other respects regarding verbatim copying of that |
| 1575 |
document. |
| 1576 |
|
| 1577 |
7. AGGREGATION WITH INDEPENDENT WORKS |
| 1578 |
|
| 1579 |
A compilation of the Document or its derivatives with other |
| 1580 |
separate and independent documents or works, in or on a volume of a |
| 1581 |
storage or distribution medium, is called an "aggregate" if the |
| 1582 |
copyright resulting from the compilation is not used to limit the |
| 1583 |
legal rights of the compilation's users beyond what the individual |
| 1584 |
works permit. When the Document is included in an aggregate, this |
| 1585 |
License does not apply to the other works in the aggregate which |
| 1586 |
are not themselves derivative works of the Document. |
| 1587 |
|
| 1588 |
If the Cover Text requirement of section 3 is applicable to these |
| 1589 |
copies of the Document, then if the Document is less than one half |
| 1590 |
of the entire aggregate, the Document's Cover Texts may be placed |
| 1591 |
on covers that bracket the Document within the aggregate, or the |
| 1592 |
electronic equivalent of covers if the Document is in electronic |
| 1593 |
form. Otherwise they must appear on printed covers that bracket |
| 1594 |
the whole aggregate. |
| 1595 |
|
| 1596 |
8. TRANSLATION |
| 1597 |
|
| 1598 |
Translation is considered a kind of modification, so you may |
| 1599 |
distribute translations of the Document under the terms of section |
| 1600 |
4. Replacing Invariant Sections with translations requires special |
| 1601 |
permission from their copyright holders, but you may include |
| 1602 |
translations of some or all Invariant Sections in addition to the |
| 1603 |
original versions of these Invariant Sections. You may include a |
| 1604 |
translation of this License, and all the license notices in the |
| 1605 |
Document, and any Warranty Disclaimers, provided that you also |
| 1606 |
include the original English version of this License and the |
| 1607 |
original versions of those notices and disclaimers. In case of a |
| 1608 |
disagreement between the translation and the original version of |
| 1609 |
this License or a notice or disclaimer, the original version will |
| 1610 |
prevail. |
| 1611 |
|
| 1612 |
If a section in the Document is Entitled "Acknowledgements", |
| 1613 |
"Dedications", or "History", the requirement (section 4) to |
| 1614 |
Preserve its Title (section 1) will typically require changing the |
| 1615 |
actual title. |
| 1616 |
|
| 1617 |
9. TERMINATION |
| 1618 |
|
| 1619 |
You may not copy, modify, sublicense, or distribute the Document |
| 1620 |
except as expressly provided under this License. Any attempt |
| 1621 |
otherwise to copy, modify, sublicense, or distribute it is void, |
| 1622 |
and will automatically terminate your rights under this License. |
| 1623 |
|
| 1624 |
However, if you cease all violation of this License, then your |
| 1625 |
license from a particular copyright holder is reinstated (a) |
| 1626 |
provisionally, unless and until the copyright holder explicitly and |
| 1627 |
finally terminates your license, and (b) permanently, if the |
| 1628 |
copyright holder fails to notify you of the violation by some |
| 1629 |
reasonable means prior to 60 days after the cessation. |
| 1630 |
|
| 1631 |
Moreover, your license from a particular copyright holder is |
| 1632 |
reinstated permanently if the copyright holder notifies you of the |
| 1633 |
violation by some reasonable means, this is the first time you have |
| 1634 |
received notice of violation of this License (for any work) from |
| 1635 |
that copyright holder, and you cure the violation prior to 30 days |
| 1636 |
after your receipt of the notice. |
| 1637 |
|
| 1638 |
Termination of your rights under this section does not terminate |
| 1639 |
the licenses of parties who have received copies or rights from you |
| 1640 |
under this License. If your rights have been terminated and not |
| 1641 |
permanently reinstated, receipt of a copy of some or all of the |
| 1642 |
same material does not give you any rights to use it. |
| 1643 |
|
| 1644 |
10. FUTURE REVISIONS OF THIS LICENSE |
| 1645 |
|
| 1646 |
The Free Software Foundation may publish new, revised versions of |
| 1647 |
the GNU Free Documentation License from time to time. Such new |
| 1648 |
versions will be similar in spirit to the present version, but may |
| 1649 |
differ in detail to address new problems or concerns. See |
| 1650 |
<https://www.gnu.org/licenses/>. |
| 1651 |
|
| 1652 |
Each version of the License is given a distinguishing version |
| 1653 |
number. If the Document specifies that a particular numbered |
| 1654 |
version of this License "or any later version" applies to it, you |
| 1655 |
have the option of following the terms and conditions either of |
| 1656 |
that specified version or of any later version that has been |
| 1657 |
published (not as a draft) by the Free Software Foundation. If the |
| 1658 |
Document does not specify a version number of this License, you may |
| 1659 |
choose any version ever published (not as a draft) by the Free |
| 1660 |
Software Foundation. If the Document specifies that a proxy can |
| 1661 |
decide which future versions of this License can be used, that |
| 1662 |
proxy's public statement of acceptance of a version permanently |
| 1663 |
authorizes you to choose that version for the Document. |
| 1664 |
|
| 1665 |
11. RELICENSING |
| 1666 |
|
| 1667 |
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any |
| 1668 |
World Wide Web server that publishes copyrightable works and also |
| 1669 |
provides prominent facilities for anybody to edit those works. A |
| 1670 |
public wiki that anybody can edit is an example of such a server. |
| 1671 |
A "Massive Multiauthor Collaboration" (or "MMC") contained in the |
| 1672 |
site means any set of copyrightable works thus published on the MMC |
| 1673 |
site. |
| 1674 |
|
| 1675 |
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 |
| 1676 |
license published by Creative Commons Corporation, a not-for-profit |
| 1677 |
corporation with a principal place of business in San Francisco, |
| 1678 |
California, as well as future copyleft versions of that license |
| 1679 |
published by that same organization. |
| 1680 |
|
| 1681 |
"Incorporate" means to publish or republish a Document, in whole or |
| 1682 |
in part, as part of another Document. |
| 1683 |
|
| 1684 |
An MMC is "eligible for relicensing" if it is licensed under this |
| 1685 |
License, and if all works that were first published under this |
| 1686 |
License somewhere other than this MMC, and subsequently |
| 1687 |
incorporated in whole or in part into the MMC, (1) had no cover |
| 1688 |
texts or invariant sections, and (2) were thus incorporated prior |
| 1689 |
to November 1, 2008. |
| 1690 |
|
| 1691 |
The operator of an MMC Site may republish an MMC contained in the |
| 1692 |
site under CC-BY-SA on the same site at any time before August 1, |
| 1693 |
2009, provided the MMC is eligible for relicensing. |
| 1694 |
|
| 1695 |
ADDENDUM: How to use this License for your documents |
| 1696 |
==================================================== |
| 1697 |
|
| 1698 |
To use this License in a document you have written, include a copy of |
| 1699 |
the License in the document and put the following copyright and license |
| 1700 |
notices just after the title page: |
| 1701 |
|
| 1702 |
Copyright (C) YEAR YOUR NAME. |
| 1703 |
Permission is granted to copy, distribute and/or modify this document |
| 1704 |
under the terms of the GNU Free Documentation License, Version 1.3 |
| 1705 |
or any later version published by the Free Software Foundation; |
| 1706 |
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover |
| 1707 |
Texts. A copy of the license is included in the section entitled ``GNU |
| 1708 |
Free Documentation License''. |
| 1709 |
|
| 1710 |
If you have Invariant Sections, Front-Cover Texts and Back-Cover |
| 1711 |
Texts, replace the "with...Texts." line with this: |
| 1712 |
|
| 1713 |
with the Invariant Sections being LIST THEIR TITLES, with |
| 1714 |
the Front-Cover Texts being LIST, and with the Back-Cover Texts |
| 1715 |
being LIST. |
| 1716 |
|
| 1717 |
If you have Invariant Sections without Cover Texts, or some other |
| 1718 |
combination of the three, merge those two alternatives to suit the |
| 1719 |
situation. |
| 1720 |
|
| 1721 |
If your document contains nontrivial examples of program code, we |
| 1722 |
recommend releasing these examples in parallel under your choice of free |
| 1723 |
software license, such as the GNU General Public License, to permit |
| 1724 |
their use in free software. |
| 1725 |
|
| 1726 |
|
| 1727 |
File: datamash.info, Node: Concept index, Prev: GNU Free Documentation License, Up: Top |
| 1728 |
|
| 1729 |
Concept index |
| 1730 |
************* |
| 1731 |
|
| 1732 |
|