Linux -- 在文件中添加信息的方法(转)

转自:https://www.cnblogs.com/ZGreMount/p/7645542.html

创建test 文件:

touch test.txt

方法一:echo 命令法:

echo "hello word" >> ./test.txt

添加单一行数

方法二:cat 命令法:

cat >>./test.txt <<EOF

>HELLO LINUX

>EOF

注:结尾的EOF要顶格,成对出现,可以其它字符代替

1 touch test.txt
2 cat >>./test.txt <<EOF
3 hello word
4 EOF

方法三:cat编辑法:

  cat >> ./test.txt (回车后开始编辑输入内容)

  I am a boy.

  按cntl+d组合键结束编辑。

方法四:vim 编辑法:

vim test.txt

i like maths

按esc 退出编辑模式,然后:wq 保存退出。

猜你喜欢

转载自www.cnblogs.com/clairedandan/p/11039495.html