问题
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