加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 防止反引号中包含的表达式在heredocs中被评估

发布时间:2020-12-15 18:59:32 所属栏目:安全 来源:网络整理
导读:参见英文答案 How to cat EOF a file containing code?3个 我有这样的文字: foo bar`which which` 如果我使用heredoc这样做,我会得到一个空白文件: ? ~ echo EOT outheredoc foo barheredoc `which which`heredoc EOT? ~ cat out? ~ 我怎样才能做到这一点
参见英文答案 > How to cat <<EOF >> a file containing code?3个
我有这样的文字:
foo bar
`which which`

如果我使用heredoc这样做,我会得到一个空白文件:

?  ~  echo <<EOT > out
heredoc> foo bar
heredoc> `which which`
heredoc> EOT
?  ~  cat out

?  ~

我怎样才能做到这一点?

编辑

哦对不起,我打算做猫.问题是它将它写入文件:which:shell内置命令,即评估反引号.没有评估,任何方式做到这一点?

有了猫,我明白了

?  ~  cat <<EOT > out
heredoc> foo bar
heredoc> `which which`
heredoc> EOT
?  ~  cat out
foo bar
which: shell built-in command
?  ~

我不想要评估哪个.

引用标签以防止反引号被评估.
$cat << "EOT" > out
foo bar
`which which`
EOT

$cat out
foo bar
`which which`

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读