Advertisement
cd62131

template replacement on gnuplot script

Jul 1st, 2017
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. #!/bin/bash -eu
  2. typeset -g tempfile
  3. template() {
  4.   local path=$1
  5.   local datetime=$2
  6.   tempfile=$(mktemp -p .)
  7.   cat <<-EOT >${tempfile}
  8.   set terminal png
  9.   set pm3d map
  10.   set output "%d%.png"
  11.   splot "%p%" u 1:2:3 notitle
  12. EOT
  13.   sed -i -e "s;%d%;${datetime};" -e "s;%p%;${path};" ${tempfile}
  14. }
  15.  
  16. for path in *.txt; do
  17.   datetime=$(head -n 1 ${path} | sed 's/^[^(]*(\([^)]*\)).*$/\1/')
  18.   template ${path} ${datetime}
  19.   gnuplot ${tempfile}
  20.   rm -f ${tempfile}
  21. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement