我想执行以下命令:
cat > template.txt [enter in the terminal] text [Ctrl+d in the terminal]
在脚本中。
有没有办法告诉脚本执行 enter\Ctrl d? 有没有办法创建一个文件并用脚本写入它?
我没有找到适合我的东西。
谢谢。
最佳答案
A Here Document我认为这有点像您所谈论内容的脚本版本,尽管从您的描述中我并不完全清楚。
#!/bin/bash
cat > template.txt <<- EOF
Here
is some
text.
EOF
Ctrl-D 本身是 EOF 字符,ASCII 4。
关于linux - 如何将 ctrl+d 插入到我的 linux 脚本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33459219/