sed and awk to find pattern and add priffix

Original File

Server1|poweredOn|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)

Need Output

Server1|poweredOn|DR|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)

Conduction to check find the string "SFCHT1" and "SR" and add prefix has "DR|T1"

Rule is if I find "SFCHT1" then this server is T1
and if it has "SR" then this server is T1 And DR

I used grep to find the and sed to replace

cat file.csv |grep "SFCHT1"|sed -e "s/poweredOn/poweredOn T1/" >> file2.csv
cat file2.csv |grep "SR"|sed -e "s/poweredOn/poweredOn DR/" >> file3.csv
cat file2.csv file3.csv > file4.csv

But i find duplicate output i need to keep only the line with DR and T1 prefix updated

Server1|poweredOn|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)
Server1|poweredOn|DR|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)

Your request is not too specific; try and adapt if it doesn't fit:

sed -r '/SFCHT1.*SR/ s/^([^|]*\|){2}/&DR|T1|/' file
Server1|poweredOn|DR|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)

Here is another solution. I'm thinking that SR and SFCHT1 should only be matched between [ and ] :

sed -e '/[[][^]]*SFCHT1[]-]/s/poweredOn/poweredOn|T1/' \
    -e '/[[][^]]*SR[]-]/s/poweredOn/poweredOn|DR/' file.csv

Example:

$ file.csv
Server1|poweredOn|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)
Server2|poweredOn|268401|[Z0110-DSP-SFCHT1-VMS-R001SM] Not SR/Server1.vmx|Red Hat Enterprise Linux 3.2 (32-bit)
Server3|poweredOn|268401|[Z0109-XXX-PFCHT2-VMS-R001SM] Not SR or SFCHT1/Server1.vmx|Solaris 3.2

$ sed -e '/[[][^]]*SFCHT1[]-]/s/poweredOn/poweredOn|T1/' \
      -e '/[[][^]]*SR[]-]/s/poweredOn/poweredOn|DR/' file.csv
Server1|poweredOn|DR|T1|268401|[Z0109-GEN-SFCHT1-VMS-R001SR] Server1/Server1.vmx|Red Hat Enterprise Linux 5 (64-bit)
Server2|poweredOn|T1|268401|[Z0110-DSP-SFCHT1-VMS-R001SM] Not SR/Server1.vmx|Red Hat Enterprise Linux 3.2 (32-bit)
Server3|poweredOn|268401|[Z0109-XXX-PFCHT2-VMS-R001SM] Not SR or SFCHT1/Server1.vmx|Solaris 3.2
perl -paF'\|' -e '$F[3] =~ /SFCHT1.+SR]/ and s/\|$F[2]/|DR|T1$&/' ranjancom2000.file

thanks all i was using the

sort -u -K1,1 

this one removing the duplicate host and keeping the host which has both "DR,H1". Need to know will there any bug using this filter for large file will it remove the host which "DR,H1" and keep only the host which has "H1"