Next: Reverse and Transpose, Previous: Field Delimiters, Up: Usage Examples [Contents][Index]
datamash
accepts column ranges such as 1,2,3 and 1-3.
Simulating input with multiple columns:
$ seq 100 | paste - - - - 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ...
The following are equivalent:
$ seq 100 | paste - - - - | datamash sum 1 sum 2 sum 3 sum 4 1225 1250 1275 1300 $ seq 100 | paste - - - - | datamash sum 1,2,3,4 1225 1250 1275 1300 $ seq 100 | paste - - - - | datamash sum 1-4 1225 1250 1275 1300 $ seq 100 | paste - - - - | datamash sum 1-3,4 1225 1250 1275 1300
Ranges can be used with multiple operations:
$ seq 100 | paste - - - - | datamash sum 1-4 mean 1-4 1225 1250 1275 1300 49 50 51 52