【vim】在vim中将unix命令执行的结果保存在vim文件中
2012-12-27 21:00
465 查看
You can combine :read with a call to Unix, to read the results of a Unix command into
your file. As a very simple example:
示例1:
:r !date (此命令是将当前日期添加到当前行)
示例2:
假设有如下文本,phone.log:
=======================
Willing, Sue 333-4444
Walsh, Linda 555-6666
Quercia, Valerie 777-8888
Dougherty, Nancy 999-0000
==========================
然后执行命令:
:r !sort phone.log
执行后,会将排过序的数据插入到当前行的下面
示例3:
Suppose you are editing a file and want to insert text from another file in the directory,
but you can’t remember the new file’s name. You could perform this task the long way:
exit your file, give the ls command, note the correct filename, reenter your file, and
search for your place.
Or you could do the task in fewer steps:
Keystrokes
:!ls
Results file1 newfile file2 practice letter
Display a list of files in the current directory. Note the correct filename. Press ENTER to
continue editing.
:r newfile
"newfile" 35 lines, 949 characters
Read in the new file.
your file. As a very simple example:
示例1:
:r !date (此命令是将当前日期添加到当前行)
示例2:
假设有如下文本,phone.log:
=======================
Willing, Sue 333-4444
Walsh, Linda 555-6666
Quercia, Valerie 777-8888
Dougherty, Nancy 999-0000
==========================
然后执行命令:
:r !sort phone.log
执行后,会将排过序的数据插入到当前行的下面
示例3:
Suppose you are editing a file and want to insert text from another file in the directory,
but you can’t remember the new file’s name. You could perform this task the long way:
exit your file, give the ls command, note the correct filename, reenter your file, and
search for your place.
Or you could do the task in fewer steps:
Keystrokes
:!ls
Results file1 newfile file2 practice letter
Display a list of files in the current directory. Note the correct filename. Press ENTER to
continue editing.
:r newfile
"newfile" 35 lines, 949 characters
Read in the new file.
相关文章推荐
- 如何将DOS下执行命令的结果信息保存到一个文件
- 如何将linux 命令的执行结果在屏幕输出的同时保存到文件
- 今天在Mac机器上使用了Flex Builder编辑了一个源代码文件,保存后使用vim命令去打开时发现系统自动在每一行的结尾添加了^M符号,其实^M在Linux/Unix中是非常常见的,也就是我们在Win中见过的/r回车符号。由于编辑软件的编码问题,某些IDE的编辑器在编辑完文件之后会自动加上这个^M符号。看起来对我们的源代码没有任何影响,其实并不然,当我们把源代码文件Check In到svn之类
- java执行几条unix命令,并将执行结果追加到文件
- 将linux 命令的执行结果在屏幕输出的同时保存到文件
- 使用vim在文件中插入命令执行的输出结果
- 使用vim在文件中插入命令执行的输出结果
- Mysql 将结果保存到文件 从文件中执行sql语句 记录操作过程(tee 命令的使用)
- 将windows命令行的结果保存到文件 (cmd命令的重定向输出)
- Flume把命令执行结果写入平面文件
- Git 使用vi或vim命令打开、关闭、保存文件
- PLSQL spool命令: 显示sql文件执行结果到日志的方法
- sqlite3 执行命令 显示结果 插入图片 保存图片 例子
- vim的保存文件和退出命令
- vim的保存文件和退出命令
- 将windows命令行的结果保存到文件 (cmd命令的重定向输出)
- vim-6 执行shell命令、文件另存为、合并文件和打开多个文件
- python 执行shell命令并将结果保存
- 开发错误日志之Unix/Linux命令未执行或无结果等且程序无错误
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce