bash:如何组装字符串:“& quot; filename = output_0.csv& quot;" [英] bash: How can I assemble the string: `"filename=output_0.csv"`

查看:74
本文介绍了bash:如何组装字符串:“& quot; filename = output_0.csv& quot;"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用bash脚本执行程序.该程序必须采用以下参数.(程序是gnuplot.)

I am using a bash script to execute a program. The program must take the following argument. (The program is gnuplot.)

gnuplot -e"filename ='output_0.csv'"'plot.p'

我需要能够汇编以下字符串:"filename ='output_0.csv'"

I need to be able to assemble the following string: "filename='output_0.csv'"

我的计划是组装字符串STRING = filename ='output_0.csv',然后执行以下操作: gnuplot -r"$ STRING"'plot.p'.请注意,我留下了STRING一词,但未突出显示stackoverflow语法样式,以强调要生成的字符串.

My plan is to assemble the string STRING=filename='output_0.csv' and then do the following: gnuplot -r "$STRING" 'plot.p'. Note I left the words STRING without stackoverflow syntax style highlighting to emphasise the string I want to produce.

我不是特别精通bash,所以我不知道该怎么做.

I'm not particularly proficient at bash, and so I have no idea how to do this.

我认为可以使用 STRING ="$ STRING"附加到字符串的代码来连接字符串?我认为这可能是必需的吗?

I think that strings can be concatenated by using STRING="$STRING"stuff to append to string? I think that may be required?

作为复杂的额外层,值0实际上是一个整数,每次运行该程序时,其值应增加1.(通过for循环完成.)如果我的程序中有 n = 1 ,如何用字符串值"或文本版本替换字符串中的 0 n的整数?

As an extra layer of complication the value 0 is actually an integer which should increment by 1 each time the program is run. (Done by a for loop.) If I have n=1 in my program, how can I replace the 0 in the string by the "string value" or text version of the integer n?

推荐答案

发布了一个答案,我以为我已经接受了,但是由于某种原因,它已被删除,可能是因为它没有完全回答问题.

An answer was posted, which I thought I had accepted already, but for some reason it has been deleted, possibly because it didn't quite answer the question.

我发布了另一个类似的问题,对此的回答也帮助我回答了这个问题.您可以在此处找到上述问题和答案: bash:作为命令执行字符串

I posted another similar question, and the answer to that helped me also answer this question. You can find said question and answer here: bash: Execute a string as a command

这篇关于bash:如何组装字符串:“& quot; filename = output_0.csv& quot;"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆