Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在shell脚本中执行q_Shell_Kdb_Q Lang - Fatal编程技术网

在shell脚本中执行q

在shell脚本中执行q,shell,kdb,q-lang,Shell,Kdb,Q Lang,我需要加载一个带有硬编码字典的q文件,插入一个键,并将字典返回的值赋给shell脚本中的环境变量 这是q中的情况: q)\l /home/.../marketconfig.q q)show marketconfig[`US] 这是我需要的形式: CONFIG=\`q /home/.../marketconfig.q ; show marketconfig[\`US]\` 谢谢你们的帮助 test.sh: #/bin/bash CONFIG=`q test.q` echo config is

我需要加载一个带有硬编码字典的q文件,插入一个键,并将字典返回的值赋给shell脚本中的环境变量

这是q中的情况:

q)\l /home/.../marketconfig.q

q)show marketconfig[`US]
这是我需要的形式:

CONFIG=\`q /home/.../marketconfig.q ; show marketconfig[\`US]\`
谢谢你们的帮助

test.sh:

#/bin/bash
CONFIG=`q test.q`
echo config is $CONFIG
测试问题:

-1 "FOO";
exit 0;
输出:

$ ./test.sh
KDB+ 2.7 2011.11.09 Copyright (C) 1993-2011 Kx Systems
l64/ ...

config is FOO

似乎对我有用-1在标准输出上打印。0N!同样有效。

这是一种将其表达为一条语句的好方法,无需更改原始文件或添加额外文件:

CONFIG=\`q<<<'system "l marketconfig.q"; show marketconfig[\\`US]'`

CONFIG=\`q在bash中,您可以使用herdoc:

#!/bin/bash
CONFIG=$(q /home/.../marketconfig.q << 'EOF'
show marketconfig[`US]
EOF
)
#/bin/bash

CONFIG=$(q/home/../marketconfig.q-1需要一个字符串,因此如果您的配置还不是字符串,则需要使用string函数或-3!