在另一个文件

时间:2017-02-22 13:51:56

标签: bash shell gnuplot

我在不同的目录中有一些文件:

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

我有一个gnuplot脚本,我手动运行到每个* / OPT目录,例如:

$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

所以,我试图为我做一个shell脚本:

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

给出错误:

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

那么,如何在此循环中加载gnuplot shell脚本?

1 个答案:

答案 0 :(得分:1)

您没有引用gnuplot中的文件名:

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