bb_get_list - ampinzonv/BB3 GitHub Wiki

Function: bb_get_list

Process a list of items and return a unique, sorted list or a frequency table.


๐Ÿ” Description

This function reads a list of items (one per line) from a file or STDIN and outputs either:

  1. A unique sorted list of items, or
  2. A table showing the frequency and relative percentage of each item (if --frequency is used).

๐Ÿ“ฅ Input

  • A plain text file where each line is a list item.
  • STDIN is supported via --input -.

๐Ÿ“ค Output

  • By default: a sorted list of unique items.
  • With --frequency: a table with columns: item, count, percent.

๐Ÿงช Examples

List unique items:

bb_get_list --input names.txt

Show frequency and percentages:

bb_get_list --input names.txt --frequency

Pipe input and save output:

cat names.txt | bb_get_list --input - --outfile sorted.txt

โš™๏ธ Usage

bb_get_list --input FILE [--outfile FILE] [--frequency] [--quiet] [--force]

๐Ÿงต Options

Option Description
--input FILE Input file or - for STDIN (required)
--outfile FILE Output file (default: STDOUT)
--frequency Show item counts and relative percentages
--quiet Suppress messages
--force Overwrite output file if it exists

๐Ÿ“Œ Notes

  • Output is sorted alphabetically by default.
  • Frequencies are based on non-empty lines only.