Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgryte/shell-compute
Collection of shell scripts for computation.
https://github.com/kgryte/shell-compute
Last synced: 25 days ago
JSON representation
Collection of shell scripts for computation.
- Host: GitHub
- URL: https://github.com/kgryte/shell-compute
- Owner: kgryte
- License: mit
- Created: 2014-10-11T02:49:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-11T23:13:41.000Z (about 10 years ago)
- Last Synced: 2024-05-02T06:17:00.052Z (6 months ago)
- Language: Awk
- Size: 152 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
shell-compute
===========> Collection of shell scripts for computation.
## Usage
To use a script, you can either stream a data file
``` bash
$ awk -f
```or pipe output from a `command`
``` bash
$ command | awk -f
```## Notes
Each program works on a single column of data. For most programs, you specify the column over which to perform the computation by passing a `col` parameter. For example,
``` bash
$ echo $'1 2\n1 2\n1 2' | awk -v col=2 -f sum.awk
# 6
```instructs `sum.awk` to sum over the second column.
## Programs
### Statistics
#### count
Compute the total number of values.
``` bash
$ echo $'1\n2\n4' | awk -f count.awk
# 3
```#### min
Compute the minimum value.
``` bash
$ echo $'5\n2\n8' | awk -v col=1 -f min.awk
# 2
```#### max
Compute the maximum value.
``` bash
$ echo $'5\n2\n8' | awk -v col=1 -f max.awk
# 8
```#### sum
Compute the sum.
``` bash
$ echo $'1\n2\n3' | awk -v col=1 -f sum.awk
# 6
```#### mean
Compute the arithmetic mean.
``` bash
$ echo $'5\n2\n8' | awk -v col=1 -f mean.awk
# 5
```#### median
Compute the median.
``` bash
$ echo $'5\n2\n8\n6' | sort -n | awk -v col=1 -f median.awk
# 5.5
```Note: the values over which to compute the median should be __sorted__.
## Examples
To run the examples, navigate to the `/examples` directory
``` bash
$ cd examples
```and run
``` bash
$ bash ./examples.sh
```## License
[MIT license](http://opensource.org/licenses/MIT).
---
## CopyrightCopyright © 2014. Athan Reines.