She*_*nan 3 linux variables gnuplot
我需要在不同的设备上运行 gnuplot 脚本。一旦我到达特定目录,设备上的文件结构是相同的,但这些目录的路径不同。我想我需要在路径名中有一个变量,我可以根据我所在的设备来更改它。
我认为以下内容会起作用,因为我在这里找到了类似的东西,但事实并非如此:
path_to_directory="/desktop/path/to/directory"
# path_to_directory="laptop/path/to/directory"
# the line above is commented out but it can be included
# if I want to switch from my desktop to my laptop
path_to_file="$path_to_directory/path/to/file"
plot path_to_file ...
Run Code Online (Sandbox Code Playgroud)
警告消息显示:正在跳过不可读的文件“$path_to_directory/path/to/file”
您知道如何在 gnuplot 脚本的路径中包含变量,以便可以在路径之间轻松切换吗?
谢谢。
在 gnuplot 中,您不需要$
像在 bash 中那样指示变量。您可以使用点进行串联操作:
path_to_directory="/desktop/path/to/directory"
path_to_file=path_to_directory."/path/to/file"
Run Code Online (Sandbox Code Playgroud)