我有一个文件如下
!J INCé0001438823
#1 A LIFESAFER HOLDINGS, INC.é0001509607
#1 ARIZONA DISCOUNT PROPERTIES LLCé0001457512
#1 PAINTBALL CORPé0001433777
$ LLCé0001427189
$AVY, INC.é0001655250
& S MEDIA GROUP LLCé0001447162
Run Code Online (Sandbox Code Playgroud)
我只想保留每行的最后 10 个字符,使其如下所示:-
0001438823
0001509607
0001457512
0001433777
0001427189
0001655250
Run Code Online (Sandbox Code Playgroud)
我会将其视为 shell 脚本问题。在vim中输入以下内容:
:%! rev|cut -c1-10|rev
Run Code Online (Sandbox Code Playgroud)
该:%!会管通过以下过滤整个缓冲区,然后过滤,从直来这里。
:%s/.*\(.\{10\}\)/\1
: ex-commaned
% entire file
s/ substitute
.* anything (greedy)
. followed by any character
\{10\} exactly 10 of them
\( \) put them in a match group
/ replace with
\1 said match group
Run Code Online (Sandbox Code Playgroud)