bash – 用heredoc扩展壳牌
发布时间:2020-12-16 01:47:02 所属栏目:安全 来源:网络整理
导读:对于所有命令,如何在heredoc中进行子 shell扩展? 例如: file=report_$(date +%Y%m%d)cat EOF $file date hostname echo 'End of Report'EOF 以便评估所有命令? 我知道 file=report_$(date +%Y%m%d)cat EOF $file $(date)) $(hostname) $(echo 'End of Rep
对于所有命令,如何在heredoc中进行子
shell扩展?
例如: file=report_$(date +%Y%m%d) cat <<EOF > $file date hostname echo 'End of Report' EOF 以便评估所有命令? 我知道 file=report_$(date +%Y%m%d) cat <<EOF > $file $(date)) $(hostname) $(echo 'End of Report') EOF 会工作,但有没有办法默认指定子shell? 解决方法
您可以使用sh(或bash)作为命令而不是cat;实际上它将作为shell脚本运行:
sh <<EOF > $file date hostname echo 'End of Report' EOF (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |