gpt4 book ai didi

linux - 如何在 block 内写入确切的字符串而不是执行它们?在 Bash 中使用 << EOF 时?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:31:21 25 4
gpt4 key购买 nike

我有一个 configure.sh 文件,其中包含以下内容(它创建了一个带有配置的 test.sh 文件,因此我最终可以将该 test.sh 用作主要配置任务)。但是没用

cat > /var/tmp/test.sh << EOF
regex='value=(.*)'
for i in $(cat /var/tmp/test.ini);
do
if [[ $i =~ $regex ]];
then
echo ${BASH_REMATCH[1]}
#or
curl -v ${BASH_REMATCH[1]}
fi
done
EOF

当执行configure.sh 时,它使test.sh 文件完全错误,例如reged='值(.*)'

for i in 
original line1
original line1
original line1
original line1
do
if [[ =~ ]];
then
fi

done
EOF

EOF block 并没有完全按照我上面的设置来写。 EOF里面怎么写这样的字符串?

最佳答案

更改 << EOF<< 'EOF'并留下 EOF最后不变。以这种方式引用 EOF 将阻止 Bash 对 here-document 执行扩展。

关于linux - 如何在 block 内写入确切的字符串而不是执行它们?在 Bash 中使用 << EOF 时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7951395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com