Script Output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Output
# 1  
Old 01-22-2014
Script Output

Input format :

HTML Code:
A,Plan name ,L,M,B,Service Name,Pricing Rule,From Unit,To Unit, DISTI(USD) , MSRP(USD) , DIST(EUR) , MSRP(EUR) , EMEA-DISTI(USD) , EMEA-MSRP(USD) , GLOBAl-DISTI(USD) , GLOBAL-MSRP(USD) , DISTI(GBP) , MSRP(GBP) 
C1,P1,L1,M1,1,S1,Standard,1,,255,300,187.85,221,255,300,255,300,151.3,178
C2,P2,L2,M2,1,S2,Standard,1,2,1,2,3,4,5,6,7,8,9,10
C3,P2,L2,M2,1,S2,Standard,3,,11,12,13,14,15,16,17,18,19,20
Output Required :

HTML Code:
<OPERATION_NAME>,<PLAN_SUB_ENTITY>,<plan_name>,<service_name>,<RATE SCHEDULE NAME>,<CURRENCY>,<IS_DEFAULT>,<From Unit>,<To Unit>,<amount>
XX,YY,P1,S1,  DISTI , USD ,0,1, ,255
XX,YY,P1,S1,  MSRP , USD ,1,1, ,300
XX,YY,P1,S1,  DIST , EUR ,0,1, ,187.85
XX,YY,P1,S1,  MSRP , EUR ,1,1, ,221
XX,YY,P1,S1,  EMEA-DISTI , USD ,0,1, ,255
XX,YY,P1,S1,  EMEA-MSRP , USD ,0,1, ,300
XX,YY,P1,S1,  GLOBAl-DISTI , USD ,0,1, ,255
XX,YY,P1,S1,  GLOBAL-MSRP , USD ,0,1, ,300
XX,YY,P1,S1,  DISTI , GBP ,0,1, ,151.3
XX,YY,P1,S1,  MSRP , GBP ,1,1, ,178
XX,YY,P2,S2,  DISTI , USD ,0,1,2,1
XX,YY,P2,S2,  MSRP , USD ,1,1,2,2
XX,YY,P2,S2,  DIST , EUR ,0,1,2,3
XX,YY,P2,S2,  MSRP , EUR ,1,1,2,4
XX,YY,P2,S2,  EMEA-DISTI , USD ,0,1,2,5
XX,YY,P2,S2,  EMEA-MSRP , USD ,0,1,2,6
XX,YY,P2,S2,  GLOBAl-DISTI , USD ,0,1,2,7
XX,YY,P2,S2,  GLOBAL-MSRP , USD ,0,1,2,8
XX,YY,P2,S2,  DISTI , GBP ,0,1,2,9
XX,YY,P2,S2,  MSRP , GBP ,1,1,2,10
XX,YY,P2,S2,  DISTI , USD ,0,3,,11
XX,YY,P2,S2,  MSRP , USD ,1,3,,12
XX,YY,P2,S2,  DIST , EUR ,0,3,,13
XX,YY,P2,S2,  MSRP , EUR ,1,3,,14
XX,YY,P2,S2,  EMEA-DISTI , USD ,0,3,,15
XX,YY,P2,S2,  EMEA-MSRP , USD ,0,3,,16
XX,YY,P2,S2,  GLOBAl-DISTI , USD ,0,3,,17
XX,YY,P2,S2,  GLOBAL-MSRP , USD ,0,3,,18
XX,YY,P2,S2,  DISTI , GBP ,0,3,,19
XX,YY,P2,S2,  MSRP , GBP ,1,3,,20

With jus one extra logic where the RATE SCHEDULE NAME is MSRP the IS_DEFAULT column should have value 1 else 0
# 2  
Old 01-22-2014
Hi, what have you tried so far?
# 3  
Old 01-22-2014
This User Gave Thanks to Akshay Hegde For This Post:
# 4  
Old 01-22-2014
For the below input

Code:
CUSTOMER_ITEM_NUMBER,Plan,L1 Supp Plan,Master Plan,Billing Interval,Service Name,Pricing Rule,From Tier,To Tier, DISTI(USD) , MSRP(USD) , DIST(EUR) , MSRP(EUR) , EMEA-DISTI(USD) , EMEA-MSRP(USD) , GLOBAl-DISTI(USD) , GLOBAL-MSRP(USD) , DISTI(GBP) , MSRP(GBP) 
HSD-B1ACP-01PT1-A1S,HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic,HS DC B1A Master Plan - Academic,1,HS DC Compute Service,Volume Discount,1,1,5527.55,6503,4068.95,4787,5527.55,6503,5527.55,6503,3275.9,3854
HSD-B1ACP-01PT2-A1S,HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic,HS DC B1A Master Plan - Academic,1,HS DC Compute Service,Volume Discount,2,3,5348.2,6292,3937.2,4632,5348.2,6292,5348.2,6292,3170.5,3730
HSD-B1ACP-01PT3-A1S,HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic,HS DC B1A Master Plan - Academic,1,HS DC Compute Service,Volume Discount,4,5,5155.25,6065,3795.25,4465,5155.25,6065,5155.25,6065,3055.75,3595

Code:
-bash-3.2$ awk 'NR==1{for(i=10;i<=NF;i++){gsub(/\(|\)/,OFS,$i);A[i]=$i}}NR>1{s=$1 OFS $2 OFS $3 OFS $4;for(i=10;i<=NF;i++)print $2,$3,A[i],$i}' FS=',' OFS=',' sample_1.txt

i'm getting the below output

Code:
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,USD, ,5527.55
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,USD, ,6503
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DIST,EUR, ,4068.95
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,EUR, ,4787
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-DISTI,USD, ,5527.55
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-MSRP,USD, ,6503
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAl-DISTI,USD, ,5527.55
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAL-MSRP,USD, ,6503
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,GBP, ,3275.9
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,GBP, ,3854
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,USD, ,5348.2
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,USD, ,6292
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DIST,EUR, ,3937.2
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,EUR, ,4632
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-DISTI,USD, ,5348.2
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-MSRP,USD, ,6292
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAl-DISTI,USD, ,5348.2
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAL-MSRP,USD, ,6292
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,GBP, ,3170.5
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,GBP, ,3730
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,USD, ,5155.25
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,USD, ,6065
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DIST,EUR, ,3795.25
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,EUR, ,4465
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-DISTI,USD, ,5155.25
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, EMEA-MSRP,USD, ,6065
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAl-DISTI,USD, ,5155.25
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, GLOBAL-MSRP,USD, ,6065
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, DISTI,GBP, ,3055.75
HS DC B1A SP Compute 1 Month Prepaid - Academic,HS DC B1A SP GA Launch - Academic, MSRP,GBP, ,3595

I want 1 where A[i] has MSRP and 0 else

---------- Post updated at 04:57 AM ---------- Previous update was at 02:04 AM ----------

Hi Can anybody help on the above .. Thanks

Last edited by Scrutinizer; 01-22-2014 at 03:06 AM.. Reason: Extra code tags for awk code
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to call and sort awk script and output

I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Discussion started by: Eric7giants
1 Replies

2. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

3. Shell Programming and Scripting

Shell Script function to use script name for log file output

Hi Team - I"m very new to Shell Scripting so I have a rather novice question. My forte is Windows Batch Scripting so I was just wondering what the Shell Script equivalent is to the DOS command %~n? %~n is a DOS variable that dispayed the script name. For instance (in DOS): REM... (11 Replies)
Discussion started by: SIMMS7400
11 Replies

4. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

5. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

6. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

7. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

8. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

9. Red Hat

Cron task output is 0, script output is OK

I have the following cron task set to run every 15 minutes to ascertain how many users are in the system and append the result to the log. /home/pronto/cus/whoisinc >> /home/pronto/cus/whoisin.log This is the whoisinc script date +"%d-%m-%Y,%k:%M,Pronto Users,`prowho -s | grep -v... (1 Reply)
Discussion started by: scottm
1 Replies

10. Shell Programming and Scripting

Running a script in system() call and want the script's output

Hi All, I have a script(sample.sh) displaying the output of "dd" command. Now i am using this script in system() call as, system("sh sample.sh") in an application file. I want the output of system("sh sample.sh") in the application file itself. How can i get it? Many thnaks.... (9 Replies)
Discussion started by: amio
9 Replies
Login or Register to Ask a Question