string="this is a sample
this is a second sample
same length the 1 above
this is a third sample"
printf '%s\n' "$string" | awk -v max=-1 '
{l = length}
l > max {max = l; output = "Max length: " max RS}
l == max {output = output NR ": " $0 RS}
END {if (max >= 0) printf "%s", output}'
Saídas:
Max length: 23
2: this is a second sample
3: same length the 1 above