I know we have some bashers (kshers? posixers?) around here. I was
writing an org-doc for my computer group, looking at gnuplot using
org-plot.

https://orgmode.org/worg/org-tutorials/org-plot.org

(Let me know if it gives you trouble)

I will also put up 'sample.csv' a; very ugly public data csv

Then we want to be able to evaluate shell:

#+begin_src elisp
(org-babel-do-load-languages 'org-babel-load-languages
'((shell . t)))
#+end_src

Now C-c C-c on a source block or call should ask to execute it, or
on a #+PLOT:   line (with results)  will gnuplot it. and here's me
trying to beat it into shape with shell in org-babel.

#+NAME: food
#+HEADER: :var IN="sample.csv" OUT="test-output.csv"
#+HEADER: :var MONTH="month-food.txt" COST="cost-food.txt"
#+HEADER: :var BEGIN=1 COUNT=12
#+HEADER: :var FOOD="apples" YEAR="2007"
#+begin_src shell
 grep -i $FOOD < $IN | grep -i $YEAR | tail -n+$BEGIN | head -n$COUNT | cut -d',' -f2 | nl | tee $MONTH 1>&2
 grep -i $FOOD < $IN | grep -i $YEAR | tail -n+$BEGIN | head -n$COUNT | cut -d',' -f3 | nl | tee $COST 1>&2

 printf "%s %s\n" "month" "Price"
 join $MONTH $COST | cut -d' ' -f2- | tee $OUT
#+end_src

#+PLOT: ind:1 deps:(2) with:histograms title:"foo"
#+RESULTS: food
|   month | Price |
| 2007.01 |  3.89 |
| 2007.02 |  2.85 |
| 2007.03 |  2.22 |
| 2007.04 |  2.02 |
| 2007.05 |  1.89 |
| 2007.06 |  1.89 |
| 2007.07 |  1.98 |
| 2007.08 |  2.11 |
| 2007.09 |  2.13 |
|  2007.1 |  2.18 |
| 2007.11 |  2.55 |
| 2007.12 |  3.24 |

Now let's use it:

#+name: apples-2007
#+CALL: food(YEAR=2007, FOOD="apples")

#+PLOT: ind:1 deps:(2) labels:("month" "price/kg") with:histograms
#+RESULTS: apples-2007

And again:

#+name: bananas-2009
#+CALL: food(YEAR=2009, FOOD="bananas")

#+PLOT: ind:1 deps:(2) labels:("month" "price/kg") with:histograms
#+RESULTS: bananas-2009

sample.csv   just has apple and banana  prices  for 2007, 2009 and
2011.