-
shell调用vim
#! /bin/bash vi test.txt << EOF i # 进入 insert 模式 Here is a document! # 输入文本内容 ^[ # 意为按下ESC退出编辑模式 :wq # 保存退出 EOF
上述脚本中,
^[
不能直接输入, 而应当先按下<c-v>
, 再按<esc>
得到
也可以使用 shell 脚本中的 here document 为 vim 提供内容 -
写入内容
echo "This is a test." >> test.txt
shell脚本中调用vim处理文档
于 2023-06-15 10:20:40 首次发布