如题!
请问:
vim 打开的buffer中有很多行, 我想把 其中的 含有 pattern 字符串的行 提取到 另一个文件 file中,
我用
:g/pattern/write file
发现不行。
请指点一二!Thks1
怎样提取 感兴趣的行,并写入 另一个文件中?
-
- 帖子: 1
- 注册时间: 2009-08-26 15:22
- 懒蜗牛Gentoo
- 论坛版主
- 帖子: 7353
- 注册时间: 2007-03-02 17:36
- 系统: Linux Mint
Re: 怎样提取 感兴趣的行,并写入 另一个文件中?
非要用vim么?
cat filename |grep pattern >> file2
cat filename |grep pattern >> file2
虽然世上没有完美的东西,但这并不影响我们追求完美,因为只有偏执狂才TMD能成功。
10.04新手入门——笨兔兔讲述自己的故事
10.04新手入门——笨兔兔讲述自己的故事
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- GiL
- 帖子: 690
- 注册时间: 2006-11-15 14:30
- 来自: 海滨小城
Re: 怎样提取 感兴趣的行,并写入 另一个文件中?
这个?You can also "write" a specific portion of a file to a new filename. By prefixing the :up
command with a line range only the specified lines are written to the named file. For example,
:20,30up 20-30.txt saves lines twenty to thirty of the current buffer to a file named
20-30.txt. Alternatively, select a portion of a file visually then execute :up filename
and the text you selected will be written to a file named filename.