description | cat with bar graph |
owner | GPL3 |
last change | Mon, 12 Dec 2022 22:56:34 +0000 (23:56 +0100) |
Visualizes relative sizes of values read from input (parameters, file(s) or STDIN). Contents are concatenated similar to cat, but numbers are reformatted and a bar graph is appended to each line.
Don't worry, barcat does not drink and divide. It can has various options for input and output (re)formatting, but remains limited to one-dimensional charts. For more complex graphing needs you'll need a larger animal like gnuplot.
Run barcat -h
to get a summary of available options:
- Usage
- barcat [<options>] [<file>... | <numbers>]
- Options
-a, --[no-]ascii
- Restrict user interface to ASCII characters
-C, --[no-]color
- Force colored output of values and bar markers
-f, --field=([+]N|REGEXP)
- Compare values after a given number of whitespace separators
--header
- Prepend a chart axis with minimum and maximum values labeled
-H, --human-readable
- Format values using SI unit prefixes
--sexagesimal
- Convert seconds to HH:MM:SS time format
-t, --interval[=(N|-LINES)]
- Output partial progress every given number of seconds or input lines
-l, --length=[-]SIZE[%]
- Trim line contents (between number and bars)
-L, --limit[=(N|-LAST|START-[END])]
- Stop output after a number of lines
-e, --log
- Logarithmic (exponential) scale instead of linear
--graph-format=CHAR
- Glyph to repeat for the graph line
-m, --markers=FORMAT
- Statistical positions to indicate on bars
--min=N, --max=N
- Bars extend from 0 or the minimum value if lower
--palette=(PRESET|COLORS)
- Override colors of parsed numbers
-_, --spark
- Replace lines by sparklines
--indicators[=CHARS]
- Prefix a unicode character corresponding to each value
-s, --stat
- Total statistics after all data
-u, --unmodified
- Do not reformat values, keeping leading whitespace
--value-length=SIZE
- Reserved space for numbers
-w, --width=COLUMNS
- Override the maximum number of columns to use
-h, --usage
- Overview of available options
--help
- Full pod documentation
-V, --version
- Version information
Draw a sine wave:
seq 30 | awk '{print sin($1/10)}' | barcat
Compare file sizes (with human-readable numbers):
du -d0 -b * | barcat -H
Same from formatted results, selecting the first numeric value:
tree -s --noreport | barcat -H -f+
Compare media metadata, like image size or play time:
exiftool -T -p '$megapixels ($imagesize) $filename' * | barcat
exiftool -T -p '$duration# $avgbitrate# $filename' * | barcat --sexagesimal
find -type f -print0 | xargs -0 -L1 \
ffprobe -show_format -of json -v error |
jq -r '.format|.duration+" "+.bit_rate+" "+.filename' | barcat --sex
Memory usage of user processes with long names truncated:
ps xo rss,pid,cmd | barcat -l40
Monitor network latency from prefixed results:
ping google.com | barcat -f'time=\K' -t
Commonly used after counting, for example users on the current server:
users | tr ' ' '\n' | sort | uniq -c | barcat
Letter frequencies in text files:
cat /usr/share/games/fortunes/*.u8 |
perl -CS -nE 'say for grep length, split /\PL*/, uc' |
sort | uniq -c | barcat
Number of HTTP requests per day:
cat httpd/access.log | cut -d\ -f4 | cut -d: -f1 | uniq -c | barcat
Any kind of database query results, preserving returned alignment:
echo 'SELECT sin(value * .1) FROM generate_series(0, 30) value' |
psql -t | barcat -u
In PostgreSQL from within the client; a fancy \dt+
perhaps:
> SELECT schemaname, relname, pg_total_relation_size(relid)
FROM pg_statio_user_tables ORDER BY idx_blks_hit
\g |barcat -uHf+
Same thing in SQLite (requires the sqlite3 client):
> .once |barcat -Hf+
> SELECT name, sum(pgsize) FROM dbstat GROUP BY 1;
Earthquakes worldwide magnitude 1+ in the last 24 hours:
curl https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_day.csv |
column -ts, -n | barcat -f4 -u -l80%
External datasets, like movies per year:
curl https://github.com/prust/wikipedia-movie-data/raw/master/movies.json -L |
jq .[].year | uniq -c | barcat
Pokémon height comparison:
curl https://github.com/Biuni/PokemonGO-Pokedex/raw/master/pokedex.json -L |
jq -r '.pokemon[] | [.height,.num,.name] | join(" ")' | barcat
USD/EUR exchange rate from CSV provided by the ECB:
curl https://sdw.ecb.europa.eu/export.do \
-Gd 'node=SEARCHRESULTS&q=EXR.D.USD.EUR.SP00.A&exportType=csv' |
barcat -f',\K' --value-length=7
Total population history in XML from the World Bank:
curl http://api.worldbank.org/v2/country/1W/indicator/SP.POP.TOTL |
xmlstarlet sel -t -m '*/*' -v wb:date -o ' ' -v wb:value -n |
barcat -f1 -H --markers=+/1e9
Population and other information for all countries:
curl http://download.geonames.org/export/dump/countryInfo.txt |
grep -v '^#\s' | column -ts$'\t' -n | barcat -f+2 -e -u -l150 -s
And of course various Git statistics, such commit count by year:
git log --pretty=%ci | cut -b-4 | uniq -c | barcat
Or the top 3 most frequent authors with statistics over all:
git shortlog -sn | barcat -L3 -s
Activity graph of the last days (substitute date -v-{}d
on BSD):
( git log --pretty=%ci --since=30day | cut -b-10
seq 0 30 | xargs -i date +%F -d-{}day ) |
sort | uniq -c | awk '$1--' | barcat --spark
Sparkline graphics of simple input given as inline parameters:
barcat -_ 3 1 4 1 5 0 9 2 4
Misusing the spark functionality to draw a lolcat line:
seq $(tput cols) | barcat --spark --indicator=- --palette=rainbow
16 months ago | v1.10 | | commit | shortlog | log | ||
17 months ago | v1.09 | | commit | shortlog | log | ||
17 months ago | v1.08 | | commit | shortlog | log | ||
4 years ago | v1.07 | | commit | shortlog | log | ||
4 years ago | v1.06 | | commit | shortlog | log | ||
4 years ago | v1.05 | | commit | shortlog | log | ||
4 years ago | v1.04 | | commit | shortlog | log | ||
4 years ago | v1.03 | | commit | shortlog | log | ||
4 years ago | v1.02 | | commit | shortlog | log | ||
4 years ago | v1.01 | | commit | shortlog | log | ||
4 years ago | v1.00 | | commit | shortlog | log | ||
4 years ago | v0.10 | | commit | shortlog | log |
16 months ago | master | shortlog | log | tree |
4 years ago | pu | shortlog | log | tree |