0
我有两个文件,即file1.sh
和file2.sh
。将查询结果分配给变量并从其他文件访问它
file1.sh
包含DB2查询,该查询返回雇员表中的雇员总数。
现在我想将员工总数分配到文件file1.sh
内的变量中。
文件1:
#!/bin/bash
#database connection goes here
echo The total number employees:
db2 -x "select count(*) from employee"
当我运行上面显示雇员的总数文件。
但
我要存储总到一些变量,并希望它从另一个文件是file2.sh
访问。
文件2:
#!/bin/bash
#Here i want to use total number of employees
#Variable to be accessed here
有没有在线终端来检查呢? – MAK
您可以从命令行运行driver.sh。您也可以从命令行运行./child.sh,并传入参数,例如syscat.columns。我在我的答案中添加了运行child.sh的示例。 –
我可以在driver.sh文件中使用'cnt'吗? – MAK