⬆️ ⬇️

Bash script for sparkles

Sparkographic (English sparkline) is a term that Edward Tufti coined to refer to word-sized, but information-dense graphs. They show the big picture where there is no place to place normal graphs with coordinate axes. Especially useful in such areas as finance and trading, sports events, scientific and medical analysis, system administration.







Zach Holman from Github wrote the Spark shell script, which builds infographics with a simple spark command directly from the shell (just add the script somewhere in $PATH ).



Spark processes any number of numbers separated by spaces, commas, etc. You can give him numbers right from the command line.

')

 > spark 0 30 55 80 33 150 ▁▂▃▅▂▇ 


Or specify any data source. For example, here is the spark scanner of earthquakes with a magnitude of more than 1.0 in the last 24 hours from the official site.



 › curl http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M1.txt --silent | sed '1d' | cut -d, -f9 | tr "\n" ',' | sed 's/ //g' | spark ▅▆▂▃▂▂▂▅▂▂▅▇▂▂▂▃▆▆▆▅▃▂▂▂▁▂▂▆▁▃▂▂▂▂▃▂▆▂▂▂▁▂▂▃▂▂▃ ▂▂▃▂▂▁▂▂▅▂▂▆▆▅▃▆ 


Other examples. View the number of commits to the repository on github, by author.



 › git shortlog -s | cut -f1 | tr "\n" ',' | sed 's/ //g' | spark ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▁▁▁▁▁▁▁▁▂▁▁▅▁▂▁▁▁▂▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁ 


Visualization code. The number of characters in each line of the spark script itself, not including empty lines.



 › awk '{ print length($0) }' spark | grep -Ev 0 | tr "\n" ',' | spark ▁▁▁▁▅▁▇▁▁▅▁▁▁▁▁▂▂▁▃▃▁▁▃▁▃▁▂▁▁▂▂▅▂▃▂▃▃▁▆▃▃▃▁▇▁▁▂▂▂▇▅▁▂▂▁▇▁▃▁▇ ▁▂▁▇▁▁▆▂▁▇▁▂▁▁▂▅▁▂▁▆▇▇▂▁▂▁▁▁▂▂▁▅▁▂▁▁▃▁▃▁▁▁▃▂▂▂▁▁▅▂▁▁▁▁▂▂▁▁▁▂▂ 


See other interesting spark usage examples here .



Python port

Port on Sea

Source: https://habr.com/ru/post/132779/



All Articles