2016-06-11 112 views
0

用法示例:回声文本输入到文件

$ startmem 
> command1 
> command2 
> command3 
> end 
$ vi mem.txt 

MEM.TXT 
------- 
command1 
command2 
command3 

所以基本上我需要的bash程序来呼应什么输入到一个文件中,不包括“端”语句。

+0

您可以随后在这种情况下使用'history | tail -3> mem.txt',尽管你必须知道你需要多少个命令 –

回答

1

只需使用cat附带here文档。

$ cat <<EOF > mem.txt 
command1 
command2 
command3 
EOF 
$ cat mem.txt 
command1 
command2 
command3