in cshell: How to I set a variable to the command line output?

折月煮酒 提交于 2020-01-06 02:27:07

问题


I do want to start a batch job that generates a jobid as output. How can I save the jobid as environmental variable and reuse it in the cshell script? Thanks and best wishes, Rollz


回答1:


Use backticks to substitute the output of a command into the command line. To set an ordinary variable:

set varname = `start_batch_job`

To set an environment variable:

setenv varname `start_batch_job`

You should generally avoid scripting in C-shell, it has lots of problems that make it poor as a scripting language. See Csh Considered Harmful. Even if you use it as your interactive shell, you can still use another shell, such as bash or ksh, as a scripting language (except for your shell startup scripts, of course).



来源:https://stackoverflow.com/questions/18001113/in-cshell-how-to-i-set-a-variable-to-the-command-line-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!