English 中文(简体)
2. 从卷宗中评估环境变量
原标题:evaluating environment variable from file in csh
  • 时间:2009-11-17 19:14:31
  •  标签:
  • csh

我有一只字面文件,内容如下:

pre_args= $REGION , xyz ,3

使用<代码>perl 可在缩略语中评估环境变量。 同样:

set pre_args = `grep -v  ^#  $config_file | grep pre_args | cut -f 2 -d = | sed  s/ //g `
if ("$pre_args" != "") then
   set pre_args = `echo $pre_args | perl -ne  use Env; s/($w+)/$1/eeg; print `
endif

如果$REGION = South ,$pre_args 现在定在:SOUTH,xyz,3

是否有办法利用军阀的固定指挥系统来做到这一点,而不必使用<代码>perl? 这样,选择使用<条码>csh就不了,因此请不作批评的答复。 感谢。

最佳回答

您可使用<条码>eval,在目前情况下,规定和执行其论点。

eval set pre_args = $pre_args

Edit: Good point re. the quotes -ink about it I m惊讶地评价了变量。 这里似乎把 e与外 s混在一起(逃避引quot),但很奇怪:

set pre_args = grep -v  ^#  config | grep pre_args | cut -f 2 -d = | sed  s/ //g  | sed "s/ /\ /g"
set REGION = SOUTH
eval set pre_args = $pre_args
echo $pre_args

参看 South , xyz ,3

问题回答

暂无回答




相关问题
ampersand at beginning of a line in csh

What does an ampersand at the beginning of a line do in csh? It seems to be ignored (with no error message), but why?

"exec source <script>" does not work in tcl

I m trying to call a script in Tcl with the command: exec source <script path> and I get the error couldn t execute "source": no such file or directory How can I call another script from tcl?...

Explain the deviousness of the Perl "preamble"

The Perl manual describes a totally devious construct that will work under any of csh, sh, or Perl, such as the following: eval (exit $?0) && eval exec perl -wS $0 ${1+"$@"} & ...

Syntax error in CShell Script

Write Script to read a positive integer number then it computes the following sequence: If the number is even, halve it If it is odd multiply it by 3 and add1 You should repeat this process until the ...

How to redirect stdout and stderr from csh script

For the following script install.csh: #!/bin/csh -f tar -zxf Python-3.1.1.tgz cd Python-3.1.1 ./configure make make install cd .. rm -rf Python-3.1.1 Intended use: ./install.csh |& tee ...

Remove symbol in shell

I m new to shell scripting, right now using csh and let s say I have a line in my configuration file like this: 127.0.0.1:2222 127.0.0.2:3333 127.0.0.3:4444 All I want is to parse it for two ...

热门标签