【发布时间】:2015-04-26 05:53:55
【问题描述】:
我可以使用单个命令创建一个名为“Procfile”的文件,其内容将是:
web: gunicorn hellodjango.wsgi --log-file -
如何在 Linux 终端中执行此操作?此外,将不胜感激 Windows 命令行 (cmd) 的答案。
提前致谢!
【问题讨论】:
标签: linux file ubuntu cmd terminal
我可以使用单个命令创建一个名为“Procfile”的文件,其内容将是:
web: gunicorn hellodjango.wsgi --log-file -
如何在 Linux 终端中执行此操作?此外,将不胜感激 Windows 命令行 (cmd) 的答案。
提前致谢!
【问题讨论】:
标签: linux file ubuntu cmd terminal
对于单行文件,您可以简单地使用echo:
echo "web: gunicorn hellodjango.wsgi --log-file -" > Procfile
对于多行文件,您可以在使用附加运算符 >> 时多次使用 echo:
echo "line1" > Procfile
echo "line2" >> Procfile
...
如果您已将文本存储在字符串中,则可以使用 echo -e,如下所示:
str="foo\nbar"
echo -e "$str"
您还可以将cat 和bash 的input output redirection 与here-document 一起用于内容:
cat > "Procfile" <<EOF
web: gunicorn hellodjango.wsgi --log-file -
EOF
【讨论】:
Also, is there a way to make multi-line without editing the original content?是什么意思
"line1\nline2" 转换为"echo "line1" > Procfile\necho "line2" etc" 对吗?即它将变成多个命令,而我想要一个命令来完成这项工作。
-e。像这样:echo -e "foo\nbar"
你也可以这样用:
cat > Procfile
Line 1
Line 2
<CTRL+D>
【讨论】: