Shell Script to Reformat a flat file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script to Reformat a flat file
# 1  
Old 06-04-2010
Network Shell Script to Reformat a flat file

Hi ,

I have a text file noname.txt containing 1000+ records like this. One of the record I have given below.

Input will b e like this

Code:
BOT:
2010/06/01 00:25:59
        21 = "private"
        Access-Method = 31
        NCC = GBR
        01 = "340806@osiris.fr.ft"
        04 = 57.250.0.210
        05 = 337
        06 = "Framed"
        07 = "PPP"
        1E = "08001961001"
        1F = "441224615080"
        28 = Stop
        29 = 0
        2A = 9321
        2B = 5409
        2C = "00045DDF"
        2D = "RADIUS"
        2E = 125
        2F = 151
        30 = 114
        31 = "Lost Carrier"
        3D = "Async"
:EOT


Output what I am expecting is
Code:
20100601#002559#private#31#GBR#osiris.fr.ft#340806#57.250.0.210#337#Framed#PPP#08001961001#441224615080#Stop#0#9321#5409#00045DDF#RADIUS#125#151#114#Lost Carrier#Async


Please let me know is this something possible in UNIX...
Please help I am in trouble.

Last edited by Franklin52; 06-04-2010 at 09:36 AM.. Reason: Please use code tags!
# 2  
Old 06-04-2010
sed -n '1,$s/ *|/#/gp' | sed -n '1,$s/| */|/gp' > $INFILE
# 3  
Old 06-04-2010
Thanks for this. However the problem is not yet solved .
Please can you advise on the following.
1. Where to pass the input file?
2. How to make it as a recursive operation to run almost 1000 times based on the number of records present in input file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk Flat File Conversion Script

In awk how would I flatten input.txt to output.txt? Input: givenname: Darth sn: Vadar mail: d.vadar@deathstar.com uid: dv12345 orclguid: 1234567890 givenname: Carlito sn: Brigante mail: c.brigante@paradise.com uid: cb12345 orclguid: 2134567890 Output: ... (3 Replies)
Discussion started by: u20sr
3 Replies

2. Shell Programming and Scripting

How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi, How to add trailer record at the end of the flat file in the unix ksh shell scripting can you please let me know the procedure Regards Srikanth (3 Replies)
Discussion started by: srikanth_sagi
3 Replies

3. UNIX for Dummies Questions & Answers

Script to pivot flat file

Hi to all, I have a file with a list of values: v1,v2,v3....,v9 need file in this format: Name1: v1 Name2: v2 Name3: v3 ... Name9: v9 Please help me out. (2 Replies)
Discussion started by: mozi
2 Replies

4. Shell Programming and Scripting

reformat data with a shell script

Can anyone help me with a shell script that can do the following: I have a data in fasta format (first line is the header, followed by a sequence of characters). >ALLLY GGCCCCTCGAGCCTCGAACCGGAACCTCCAAATCCGAGACGCTCTGCTTATGAGGACCTC GAAATATGCCGGCCAGTGAAAAAATCTTGTGGCTTTGAGGGCTTTTGGTTGGCCAGGGGC... (5 Replies)
Discussion started by: manishabh
5 Replies

5. Shell Programming and Scripting

reading fixed length flat file and calling java code using shell scripting

I am new to shell scripting and I have to to the following I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file. Like the following str00001.txt StoreName emailaddress location... (3 Replies)
Discussion started by: willywilly
3 Replies

6. Shell Programming and Scripting

Shell script to email based on flat file output

Hi All, I am a newbee in unix but still have written a shell script which should trigger a mail based on certain conditions but the problem is that my file is not being read. Below is the code please advise. I do not know where is it failing. Note $ and the no followed with it is the no of... (1 Reply)
Discussion started by: apoorva
1 Replies

7. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

8. Shell Programming and Scripting

urgent-extracting block data from flat file using shell script

Hi, I want to extract block of data from flat file. the data will be like this start of log One two three end of log i want all data between start of log to end of log i.e One two three to be copied to another file. This particular block may appear multiple times in same file. I... (4 Replies)
Discussion started by: shirish_cd
4 Replies

9. UNIX for Advanced & Expert Users

How to write Flat Files by shell script using Oracle Database

Hello There.. I came to a situation where I need to write flat files using shell scripts, I need to pull the records from the oracle database and create the flat file, This process should be automated. Can any shell script expert out here to help me.. please.. Will be really glad to... (3 Replies)
Discussion started by: coolbuddy
3 Replies

10. Shell Programming and Scripting

How To create Flat Files using Unix Shell Script?

Hi all, How to create Flat Files using Unix Shell Script. The Script is supposed to be sheduled to run at a particular time? Thanks in advance Appu (4 Replies)
Discussion started by: Aparna_k82
4 Replies
Login or Register to Ask a Question