spinsnip(){ if [ $# -ne 1 ]; then >&2 echo "Usage: spinsnip <report name> [other args]*" return fi reportName=$1 tmpR=$(echo $reportName | tr " " "_").R ## http://stackoverflow.com/questions/11454343/pipe-output-to-bash-function cat | sed 's/#>/#'"'"'/g' > $tmpR echo "spining $tmpR..." shift spin.R $tmpR $* rm $tmpR } ## usage example # echo ' # > # test report # 1+1; # ggplot(iris, aes(Sepal.Width) + geom_histogram() # ' | spinsnip some_report