Write output to a file using Korn shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Write output to a file using Korn shell script
# 1  
Old 05-21-2011
Write output to a file using Korn shell script

All,

Can anyone please help me with the below scenario in korn shell script.
Can anyone please give me some hints to proceed on this.

I have a Flat file of the below format.

Input file format:

Code:
ID|Name|Level|Type|Zip|MAD|Risk|Band|Salesl|Dealer|CID|AType|CValue|LV|HV|DCode|TR|DU|NStartDate|Use rRole|WFlag|EOption|PName|NActivationDate|Os|Orig|Cus|OType|ORequired|DType
03| Prog|3||90001,90002,90003,90004-90006,90007,90008|881,866,862-839,828||99-99,88-88,11-19||||REG||||MOQA,MODD,9999,8229,8228,8227,8226||||Confffers||Leased|||FREE-TO-GO-2011,FREE-TO-GO-2012|NMS|new|Acquis,Acquis|mandat,mandat|


Rules

File Column delimiter is |
ID column will not have multipe values seperated by commas.
Columns which have values separated by commas, should be made into a New row.
Columns which do not have values , no need make them into New row.
Last column Orequired is to be concatenated with appropriate Os value in order as highlited below.


Output file format requested


Code:
ID|Col_Name|Value
03|Name|Prog
03|Level|3
03|Zip|90001
03|Zip|90002
03|Zip|90003
03|Zip|90004-90006
03|Zip|90007
03|Zip|90008
03|MAD|881
03|MAD|866
03|MAD|862-839
03|MAD|828
03|BAND|99-99
03|BAND|88-88
03|BAND|11-19
03|AType|REG
03|DCode|MOQA
03|DCode|MODD
03|DCode|9999
03|DCode|8229
03|DCode|8228
03|DCode|8227
03|DCode|8226
03|UserRole|Confffers
03|EOption|Leased
03|Os|FREE-TO-GO-2011
03|Os|FREE-TO-GO-2012
03|Orig|NMS
03|Cus|new
03|OType|Acquis
03|OType|Acquis
03|ORequired|FREE-TO-GO-2011/mandat
03|ORequired|FREE-TO-GO-2012/mandat


Last edited by radoulov; 05-21-2011 at 05:38 PM.. Reason: Code tags.
# 2  
Old 05-21-2011
Hi,

Did you try something in korn shell that you can show so we have something to talk about ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed with File Checker Korn Shell Script

I am attempting to write a korn shell script that does the following, but I am getting errors. I'm new to korn shell scripting and am not sure what I am doing wrong. Please help with example scripts. Thanks. 1) check for day of the week 2) if day of the week is Monday then check for the... (4 Replies)
Discussion started by: ijmoore
4 Replies

2. UNIX for Beginners Questions & Answers

Not able to write SQL query output in to .csv file with shell script.

I am trying to write SQL query output into a .csv file. But in the output columns are displaying in different lines instead of coming in one line. Main Code shell script: this is my code: #!/bin/bash file="db_detail.txt" . $file rm /batch/corpplan/bin/dan.csv... (6 Replies)
Discussion started by: sandeepgoli53
6 Replies

3. Shell Programming and Scripting

Help with korn shell script to get the latest file versions in a directory

I want to write a korn shell script to get the latest three versions for a file in the directory having lot of files with various versions (files with prefix as same but time stamp as suffix) and compress it and at the same time have to remove the remaining versions of the file (other than latest... (4 Replies)
Discussion started by: maheshbabu
4 Replies

4. Shell Programming and Scripting

Validate file count in korn shell script

Hi, I have files in the directory like below which I need to validate if all the required files are present. A_B_001 of 002_time1.txt A_B_002 of 002_time1.txt A_B_001 of 001_time2.txt Scenarios- a)If file with 001 of 002_time1 or 002 of 002_time1 is missing in the folder,script should... (6 Replies)
Discussion started by: aneeta13
6 Replies

5. Shell Programming and Scripting

Write Awk output to a file , inside script.

Hi, Can anyone please help me with this issue. I have a Awk command which take file as input, and provides the output having multiple lines, its working in command mode, but not if i plug it in script. #!/bin/ksh infile=a.txt outfile=b.txt awk ' BEGIN{ FS=OFS="|";ORS = "\n";... (1 Reply)
Discussion started by: sp999
1 Replies

6. Shell Programming and Scripting

Help me to write as korn shell script

Hi.. This is step to telnet from linux to my window telnet server and run a program called CLISMS.exe. As your information, the program will be sent out a sms to my mobile number. The step as below:- telnet 123.123.123.123 Trying 123.123.123.123... Connected to 123.123.123.123. Escape... (1 Reply)
Discussion started by: bh_hensem
1 Replies

7. Shell Programming and Scripting

Monitor file generation for an hour using Korn shell script

Hi, I am new to this unix scripting, I got a requirement like.. Files with *.XML extension will be generating in a /home/sample/ folder for every 15 mins. I need to monitor those files in that particular folder for every hour. If no file has been generated in that particular folder for an... (7 Replies)
Discussion started by: siri_886
7 Replies

8. Shell Programming and Scripting

How to write comments in Korn shell script

What is the syntax for writing comment code in Korn shell scripts? (1 Reply)
Discussion started by: sasaliasim
1 Replies

9. UNIX for Dummies Questions & Answers

korn shell script to keep history of same file

Hello, How do I write a korn shell that will rename file with the current date. What I want to do is, I have a file that is re-written every day. But instead, I want to keep a 14 day history of the file. So I want to write a script that will rename the current file with a date attached to the... (2 Replies)
Discussion started by: watson2000
2 Replies

10. Shell Programming and Scripting

Korn Shell Script - Read File & Search On Values

I am attempting to itterate through a file that has multiple lines and for each one read the entire line and use the value then to search in other files. The problem is that instead of an entire line I am getting each word in the file set as the value I am searching for. For example in File 1... (2 Replies)
Discussion started by: run_unx_novice
2 Replies
Login or Register to Ask a Question