Thanks for your reply.
My main problem facing is I not sure how to replace the "" into "|" after I find "pir||" in the data set
I hope to replace "pir||" into "pir|' and at the same time follow by replace the next shown "" into "|".
I just wanna to replace only the first "" shown when the data got "pir||" or else just print the original data set.
If I used the sed command that you mention. It will replace all the "" into "|" which might be different with my desired output result
sed 's/pir||/pir|/
t secrepl
b
:secrepl
s/\(pir|[^_]*\)_/\1|/' file
I am assuming that if both pir| and pir|| occur in a line, then the latter comes first and pir|| occurs only once in a line. If these assumptions don't hold good for your data, then you might need to change the sed command a bit. In that case, let me know.