#!/bin/bash
s='abc,123,mno,xyz,1234
mno,123,abc,rpt,pqr,2345
xyz,456,uyt,rtp,rto,'
awk  -F, '{s=(NF==6 ? $3","$4 : $3); print s}'  <<< "$s"