如何将ctrl + d插入我的linux脚本中? [英] how to insert ctrl+d into my linux script?
本文介绍了如何将ctrl + d插入我的linux脚本中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要执行以下命令:
cat> template.txt [在终端输入] 文本 [在终端中按Ctrl + d]
cat > template.txt [enter in the terminal] text [Ctrl+d in the terminal]
在脚本中.
是否有一种方法告诉脚本执行enter \ Ctrl d? 有没有办法创建文件并用脚本写入文件?
Is there a way to tell the script to do enter\Ctrl d? Is there a way to create a file and write to it in script?
我没有找到对我有用的东西.
I didn't find anything that worked for me.
谢谢.
推荐答案
A 此处文档我认为,这有点像您正在谈论的内容的脚本版本,尽管从您的描述中对我来说还不是很清楚.
A Here Document is kind of like a script version of what you're talking about, I think, although it is not entirely clear to me from your description.
#!/bin/bash
cat > template.txt <<- EOF
Here
is some
text.
EOF
Ctrl-D本身是 EOF字符ASCII 4.
Ctrl-D itself is the EOF character, ASCII 4.
这篇关于如何将ctrl + d插入我的linux脚本中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文