如何读取文件内容作为shell脚本的单个参数

时间:2020-01-13 15:58:44

标签: shell cat

我想将参考文件作为参数传递给Shell脚本

ref.file包含

no=1
desc="query 0 "
src_txt="select count(1) from source"
trg_txt="select count(1) from target"
flag=c

no=2
desc="query 1 "
src_txt="select count(1) from source1"
trg_txt="select count(1) from target1"
flag=c

no=3
desc="query 2 "
src_txt="select count(1) from source2"
trg_txt="select count(1) from target2"
flag=c

以此类推...

shell comamnd-sh generic.sh $(cat ref.txt )

内部shell脚本中,我正在尝试阅读ref.txt的内容

echo“ ref--” $ 1

仅打印第一行,即no = 1 如果我使用$ 2,依此类推,它将仅显示少量单词,而不显示整个文本

如何在一个包含换行符的变量中读取整个文件,以及如何一次遍历ref文件中的其他查询

0 个答案:

没有答案
相关问题