Renaming files
作者:
shuff1e | 来源:发表于
2018-03-20 16:15 被阅读3次
Renaming files *rename-files*
Say I have a directory with the following files in them (directory picked at
random :-):
buffer.c
charset.c
digraph.c
...
and I want to rename *.c *.bla. I'd do it like this:
$ vim
:r !ls *.c
:%s/\(.*\).c/mv & \1.bla
:w !sh
:q!
==============================================================================
- :r !ls *.c 将文件名读入缓冲区
- :%s/(.).c/mv & \1.bla 中(.)明显就是分组啦,\1就是后向引用,$应该是引用前面的整个内容吧,这个之前没有看到过,mv就是重命名啦
- :w !sh 在当前shell中执行当前缓冲区的每行内容
-
![](https://img.haomeiwen.com/i8077007/703e09922f67b101.png)
image.png
-
image.png
本文标题:Renaming files
本文链接:https://www.haomeiwen.com/subject/vgfufftx.html
网友评论