You could split the 2nd field on `:` and if you get more than 2 pieces keep only the 1st one: awk '{n=split($2, z, ":");if (n > 2) $2=z[1]};1' infile