Hello,
I think you missed one space in the xargs expression between -I_ and n1 "xargs -I_ -n1", in your script is writing "xargs-I_-n1", so "_" is not being replaced by your virtual server name and you send to tmsh "tmsh modify ltm virtual _" and virtual _ does not exit.
tmsh list ltm virtual one-line|grep old-cert|cut -d' ' -f3| xargs -I_ -n1 tmsh modify ltm virtual _ profiles delete { old-cert } profiles add { new-cert }
If this does not solve the problem, I recomend you check procedure step by step:
Check virtual with the profils "old-cert":
tmsh list ltm virtual one-line|grep old-cert
Capture virtual names:
tmsh list ltm virtual one-line|grep old-cert|cut -d' ' -f3
....