Here’s a solution using awk
awk -F ';' '{same=1; for (i=3;i<NF;i++) { if ($i != $2) { same=0 } }; if (same == 1) {print $0}}' file
Here’s how it works
'{
same=1; #assume all fields are the same
for (i=3;i<NF;i++) { #for each field after the second
if ($i != $2) { same=0 } #test if the field is the same as
#the second
};
if (same == 1) {print $0} #if no difference were found, print the line
}'
solved i have a file all field are same then print line in bash? field is not fix [closed]