【发布时间】:2019-08-27 13:41:02
【问题描述】:
我希望能够以类似于 hereDOC 的方式从终端交互式获取输出。即我希望用户能够键入多行,然后将该信息传递到一个文件中,并保留所有格式。像这样的。
echo "Type your message below. To finish the letter type DONE by itself on a line"
file=mktmp
cat << DONE > $file
显然这不起作用,因为 EOF 是在 DONE 之前找到的。我考虑过将用户传递给 VIM 之类的东西,但我不太懂电脑的同事很难使用 vim/emacs/nano。
【问题讨论】:
-
使用
$EDITOR,你的同事可以设置EDITOR=their-editor-of-choice。 -
直接从标准输入读取将远不如任何编辑器对用户友好。
标签: bash user-interface stdin