I'm looking for a way to find all duplicate lines which are not not a color and add is a color at the end of second occurrence of them.Here is a diff -y of what I'm talking about.orginal file  - final resaultpink            pinkpink          | pink is a colornot a color     not a colornot a color     not a color violet          violetviolet        | violet is a colornot a color     not a colornot a color     not a colororange          orangeorange        | orange is a colornot a color     not a color
How to edit second occurrence of duplicate lines?
text processing;awk;sed
awk approach:awk '{print $0; if((getline nl) > 0){ print ($0!=not a color && $0 == nl)?      nl=$0 is a color : nl }}' fileThe output:pinkpink is a colornot a colornot a colorvioletviolet is a colornot a colornot a colororangeorange is a colornot a colorYou can use getline var to read the next record from awks input  into the variable var.The getline command returns 1 if it finds a record and 0 if  it encounters the end of the file.$0!=not a color && $0 == nl - if current record is not not a color string AND 2 consequtive lines are equal (dupicates)An additional approach using substr() function (to insert  is a color  string after the first 2 chars of the crucial duplicate color):awk '{print $0; if((getline nl) > 0){ print ($0!=not a color && $0 == nl)?      nl=substr($0,1,2) is a color substr($0,3) : nl }}' fileThe output would be:pinkpi is a color nknot a colornot a colorvioletvi is a color oletnot a colornot a colororangeor is a color angenot a color