srilu
May 15, 2017, 2:19pm
1
Hello All
I have request below. Please Help
Below is the input.
mrkInternetMedicalSpecialtyAlt=<order>0</order>
<code>PED</code>
Need Output as below
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>PED</code>
Value "PED" is not always same.
Hello srilu,
Welcome to forums. Could you please try following, since you have provided only this much sample so solution is as per sample Input_file only.
Solution 1st:
awk -v FS="\n" '{for(i=1;i<=NF;i++){print $i}} END{print RS}' ORS="" Input_file
Solution 2nd:
awk -v RS="" '{for(i=1;i<=NF;i++){print $i}} END{print "\n"}' ORS="" Input_file
Thanks,
R. Singh
srilu
May 15, 2017, 3:23pm
3
Hello Sorry for incomplete information.Please fidn below
Inout
:
cn=8574e029a4510e54ad6a078e55ce2c16b824a7deee29376abd
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>IM</code>
cn=f98fc9e16c1cee0a1dd587f5fe3a4f8db7ebfac1ee29376d1f
mrkInternetMedicalSpecialtyAlt=<order>0</order>
<code>GP</code>
cn=d92a1608290a5afc4c7bffb18b8a8fc5a99f2519ee293778d8
Output
:
cn=8574e029a4510e54ad6a078e55ce2c16b824a7deee29376abd
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>IM</code>
cn=f98fc9e16c1cee0a1dd587f5fe3a4f8db7ebfac1ee29376d1f
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>GP</code>
cn=d92a1608290a5afc4c7bffb18b8a8fc5a99f2519ee293778d8
Hello srilu,
Could you please try following and let me know if this helps you.
awk '{VAL=$0 !~ /^<code/?(VAL?VAL ORS $0:$0):(VAL?VAL $0:$0)} END{print VAL}' Input_file
Thanks,
R. Singh
srilu
May 15, 2017, 3:49pm
5
Thank YOu.
Executed minutes ago and i'm waiting for it to finish
srilu
May 15, 2017, 4:36pm
6
I just noticed that command above is not written anything on input file ,its idle
---------- Post updated at 04:36 PM ---------- Previous update was at 03:59 PM ----------
Can you help on this.
Hello Srilu,
Rushing while posting your questions will not help us. I think you have never posted like you want the changes inside the Input_file? If this is the case then you may need to take the output of my command into a temp_file and then rename it again as your Input_file like as follows.
awk '{VAL=$0 !~ /^<code/?(VAL?VAL ORS $0:$0):(VAL?VAL $0:$0)} END{print VAL}' Input_file > temp_file && mv temp_file Input_file
I hope this helps you, if your requirement is different then please take sometime and rephrase your questions in detailed manner so that we could try to help you.
Thanks,
R. Singh