gpt4 book ai didi

bash - 如何在 bash here-document 中键入制表符?

转载 作者:行者123 更新时间:2023-11-29 08:43:46 25 4
gpt4 key购买 nike

here-document 的定义在这里: http://en.wikipedia.org/wiki/Here_document

如何在 here-document 中键入制表符?比如这样:

cat > prices.txt << EOF
coffee\t$1.50
tea\t$1.50
burger\t$5.00
EOF

更新:

本题处理的问题:

  1. 扩展制表符
  2. 同时不展开美元符号
  3. 在脚本等文件中嵌入 here-doc

最佳答案

TAB="$(printf '\t')"

cat > prices.txt << EOF
coffee${TAB}\$1.50
tea${TAB}\$1.50
burger${TAB}\$5.00
EOF

关于bash - 如何在 bash here-document 中键入制表符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3731513/

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