chore(unitproc/bkt-processArgs):Update with die()
[BK-2020-03.git] / unitproc / bkt-decimate
CommitLineData
db51b505
SBS
1#!/bin/bash
2
3decimate() {
4 # Desc: Randomly remove 10% of stdin lines
753047a3 5 # Depends: Bash 5.1.16; GNU Coreutils 8.32 (shuf, nl, head, sort, cut)
db51b505
SBS
6 # Version: 0.0.1
7
8 # Read lines
9 mapfile -t lines;
10
11 # Calc lines to keep, lk
12 lc="${#lines[@]}";
13 lk="$((lc * 900 / 1000))";
14
f87764cc 15 # Output
db51b505
SBS
16 printf "%s\n" "${lines[@]}" | \
17 nl -w1 -s' ' | \
18 shuf | \
19 head -n "$lk" | \
20 sort -n -k1,1 | \
21 cut -d' ' -f2- ;
22}; # randomly eliminate 10% of lines
23
24echo "$WARNING:This is a Bash function definition."