我有一个像这样的 shell 脚本 -
codes=('B4036' 'B9002')
query=$(cat <<EOF
WITH claims AS
(
SELECT code, month, patient
FROM lines
WHERE code = 'proc_codes'
)
EOF
)
for i in "${codes[@]}"
do
sql=$(echo $query | sed -e "s/proc_codes/$i/g")
done
当我打印 sql
时,我得到
WITH claims AS ( SELECT code, month, patient FROM lines WHERE code = '\''B4036'\'' )
为什么我在 '\''
附近收到 proc_codes
?我如何让上面的行成为 -
WITH claims AS ( SELECT code, month, patient FROM lines WHERE code = 'B4036' )