First Time need help on UNIX Command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting First Time need help on UNIX Command
# 1  
Old 05-15-2017
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:
Mod Comment 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.
# 2  
Old 05-15-2017
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
# 3  
Old 05-15-2017
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 05-15-2017
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
# 5  
Old 05-15-2017
Thank YOu.

Executed minutes ago and i'm waiting for it to finish
# 6  
Old 05-15-2017
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.
# 7  
Old 05-16-2017
Quote:
Originally Posted by srilu
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..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Arduino UNIX Time - Syncing Computer UNIX Time to Arduino Time with Python

Just finished a quick Python script to send the current unix time over to the Arduino from macOS, so in the absence of GPS or some other way to get the unix timestamp (epoch time) to the Arduino, I can get my macOS and Arduino UNO synced to within a second. Normally, when the Arduino starts... (9 Replies)
Discussion started by: Neo
9 Replies

2. Shell Programming and Scripting

Convert UTC time into current UNIX sever time zone

Hi guys thanks for the help for my previous posts.Now i have a requirement that i download a XMl file which has UTC time stamp.I need to convert UTC time into Unix server timezone. For ex if the time zone of unix server is CDT then i need to convert into CDT.whatever may be the system time... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

3. Shell Programming and Scripting

UNIX time command implementation

I want to know about the time command flow of execution. I have a doubt in the time calculation for the command execution. Whether the real time is sum of (time taken to open the unix window + execute the command given infront of the "time" command + close the unix window) or Just the time... (1 Reply)
Discussion started by: sateesh Solapur
1 Replies

4. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

5. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

6. Shell Programming and Scripting

Changing the format of the unix time command

Hello. I use time in order to calculate the execution time of a program. The output format is: real 0m0.059s user 0m0.028s sys 0m0.004s Is there a simple and elegant way to add user and sys together, and convert to milliseconds? Thanks a lot! (4 Replies)
Discussion started by: dynelight
4 Replies

7. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

8. UNIX for Advanced & Expert Users

To find the time of excution of a particular unix command

Hi experts, It would be grateful if you can guide me on the following, 1.How to find the time of excution of a particular unix command. 2. How to find the terminal (IP Address) from where that particular unix command was excuted. 3. How to find the user who executed that particular unix... (1 Reply)
Discussion started by: apsprabhu
1 Replies

9. UNIX for Advanced & Expert Users

How To Provide Time Sync Using Nts-150 Time Server On Unix Network?

can anybody tel lme,how to instal NTS -150 on a unix network,it needs some patch to fetch time frm serve,,?? (2 Replies)
Discussion started by: pesty
2 Replies
Login or Register to Ask a Question