小编gra*_*red的帖子

如何使用 awk 重命名重复的行?

我有一个包含 100 万行的文件,有些行是重复的。我想通过附加“变体”+一个数字来重命名重复的行。该文件的格式如下:

I am a test line
She is beautiful
need for speed
Nice day today
I am a test line
stack overflow is fun
I am a test line
stack overflow is fun
I have more sentences
I am a test line
She is beautiful
Speed for need
stack overflow is fun
Let's stop here
Run Code Online (Sandbox Code Playgroud)

预期结果:

    I am a test line
    She is beautiful
    need for speed
    Nice day today
    I am a test line variant 1
    stack …
Run Code Online (Sandbox Code Playgroud)

awk rename duplicates

2
推荐指数
1
解决办法
612
查看次数

标签 统计

awk ×1

duplicates ×1

rename ×1