BaRud
BaRud

Reputation: 3218

run gnuplot in shellscript in different file

I have some files in different directory as:

ls */OPT/jij_Fe-Fe*.dat 
10/OPT/jij_Fe-Fe.dat   4/OPT/jij_Fe-Fe.dat    8/OPT/jij_Fe-Fe.dat 
267/OPT/jij_Fe-Fe.dat  545/OPT/jij_Fe-Fe.dat 2/OPT/jij_Fe-Fe.dat              
6/OPT/jij_Fe-Fe.dat

I have a gnuplot script, which I run by manually going to each */OPT directory, eg:

$cd 10/OPT/
$gnuplot
    Version 5.0 patchlevel 5    last modified 2016-10-02

    Copyright (C) 1986-1993, 1998, 2004, 2007-2016
    Thomas Williams, Colin Kelley and many others

    gnuplot home:     http://www.gnuplot.info
    faq, bugs, etc:   type "help FAQ"
    immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'wxt'
gnuplot> load '~/gnuplot.dem'   #(save the file manually)
gnuplot> exit
cd ../../6/OPT

So, I was trying to have a shell script to do this for me:

#!/bin/bash
BASEDIR=$PWD
echo "$BASEDIR"
for i in */OPT/
do
  cd $i
  gnuplot -e "load ~/gnuplot.dem"
  cd $BASEDIR
done

which is giving error:

load ~/gnuplot.dem
      ^
line 0: invalid expression 

So, how can I load the gnuplot shell script in this loop?

Upvotes: 1

Views: 538

Answers (1)

chepner
chepner

Reputation: 530960

You aren't quoting the file name in gnuplot:

gnuplot -e "load '~/gnuplot.dem'"

Upvotes: 1

Related Questions