在cshell中:如何将一个变量设置为命令行输出? [英] in cshell: How to I set a variable to the command line output?

查看:218
本文介绍了在cshell中:如何将一个变量设置为命令行输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动一个生成作业作为输出的批处理作业。
如何将jobid保存为环境变量并在cshell脚本中重新使用?
感谢和祝福,
Rollz

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

推荐答案

使用反引号将命令的输出替换为命令行。设置一个普通变量:

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

set varname = `start_batch_job`

设置环境变量:

setenv varname `start_batch_job`

你通常应该避免在C-shell中编写脚本,它有很多问题,脚本语言请参阅 Csh认为有害的。即使您使用它作为交互式shell,您仍然可以使用另一个shell,如bash或ksh作为脚本语言(当然,除了shell启动脚本)。

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).

这篇关于在cshell中:如何将一个变量设置为命令行输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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