Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

First Time need help on UNIX Command

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
srilu srilu is offline
Registered User
 
Join Date: May 2017
Last Activity: 15 May 2017, 6:14 PM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
First Time need help on UNIX Command

Hello All

I have request below. Please Help

Below is the input.


Code:
mrkInternetMedicalSpecialtyAlt=<order>0</order>
<code>PED</code>

Need Output as below


Code:
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>PED</code>

Value "PED" is not always same.


Moderator's Comments:
First Time need help on UNIX Command Please use correct CODE tags as required by forum rules!

Last edited by RudiC; 05-16-2017 at 03:03 AM.. Reason: Changed CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
RavinderSingh13 RavinderSingh13 is online now Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 21 November 2017, 10:30 PM EST
Location: Chennai
Posts: 2,670
Thanks: 588
Thanked 1,272 Times in 1,145 Posts
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:

Code:
awk -v FS="\n" '{for(i=1;i<=NF;i++){print $i}} END{print RS}' ORS=""   Input_file

Solution 2nd:

Code:
awk -v RS="" '{for(i=1;i<=NF;i++){print $i}} END{print "\n"}' ORS=""   Input_file

Thanks,
R. Singh
Sponsored Links
    #3  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
srilu srilu is offline
Registered User
 
Join Date: May 2017
Last Activity: 15 May 2017, 6:14 PM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hello Sorry for incomplete information.Please fidn below



Inout:


Code:
cn=8574e029a4510e54ad6a078e55ce2c16b824a7deee29376abd
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>IM</code>

cn=f98fc9e16c1cee0a1dd587f5fe3a4f8db7ebfac1ee29376d1f
mrkInternetMedicalSpecialtyAlt=<order>0</order>
<code>GP</code>

cn=d92a1608290a5afc4c7bffb18b8a8fc5a99f2519ee293778d8


Output:


Code:
cn=8574e029a4510e54ad6a078e55ce2c16b824a7deee29376abd
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>IM</code>

cn=f98fc9e16c1cee0a1dd587f5fe3a4f8db7ebfac1ee29376d1f
mrkInternetMedicalSpecialtyAlt=<order>0</order><code>GP</code>

cn=d92a1608290a5afc4c7bffb18b8a8fc5a99f2519ee293778d8


Last edited by Don Cragun; 05-15-2017 at 09:21 PM.. Reason: Fix ICODE tags; add CODE tags.
    #4  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
RavinderSingh13 RavinderSingh13 is online now Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 21 November 2017, 10:30 PM EST
Location: Chennai
Posts: 2,670
Thanks: 588
Thanked 1,272 Times in 1,145 Posts
Hello srilu,

Could you please try following and let me know if this helps you.

Code:
awk '{VAL=$0 !~ /^<code/?(VAL?VAL ORS $0:$0):(VAL?VAL $0:$0)} END{print VAL}'   Input_file

Thanks,
R. Singh
Sponsored Links
    #5  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
srilu srilu is offline
Registered User
 
Join Date: May 2017
Last Activity: 15 May 2017, 6:14 PM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thank YOu.

Executed minutes ago and i'm waiting for it to finish
Sponsored Links
    #6  
Old Unix and Linux 05-15-2017   -   Original Discussion by srilu
srilu srilu is offline
Registered User
 
Join Date: May 2017
Last Activity: 15 May 2017, 6:14 PM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #7  
Old Unix and Linux 05-16-2017   -   Original Discussion by srilu
RavinderSingh13 RavinderSingh13 is online now Forum Advisor  
Registered User
 
Join Date: May 2013
Last Activity: 21 November 2017, 10:30 PM EST
Location: Chennai
Posts: 2,670
Thanks: 588
Thanked 1,272 Times in 1,145 Posts
Quote:
Originally Posted by srilu View Post
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.

Code:
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

Last edited by RavinderSingh13; 05-16-2017 at 02:50 AM..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
UNIX time command implementation sateesh Solapur Shell Programming and Scripting 1 11-14-2013 08:07 AM
Changing the format of the unix time command dynelight Shell Programming and Scripting 4 07-26-2011 05:20 PM
To find the time of excution of a particular unix command apsprabhu UNIX for Advanced & Expert Users 1 05-14-2009 04:07 AM
How To Provide Time Sync Using Nts-150 Time Server On Unix Network? pesty UNIX for Advanced & Expert Users 2 03-22-2007 03:20 AM



All times are GMT -4. The time now is 11:52 PM.