Formatting a text file to get data in exact line by line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Formatting a text file to get data in exact line by line
# 1  
Old 07-02-2009
Formatting a text file to get data in exact line by line

I have my data something like this
Code:
    SERIAL FIRSTOCCURRENCE
NETPROTOCOL
1947430693 07/01/2009 05:16:40
FR
 
    SERIAL FIRSTOCCURRENCE
NETPROTOCOL
1947430746 07/01/2009 05:18:05
FR

I want the output as follows.
Code:
SERIAL.......................FIRSTOCCURRENCE.........................NETPROTOCOL
1947430693...................07/01/2009 05:16:40.....................FR
SERIAL.......................FIRSTOCCURRENCE.........................NETPROTOCOL
1947430746...................07/01/2009 05:18:05.....................ATM

i kept .... just for understanding..I don't want that in my final output. I searched this forum for the solution. But didn't get the solution.
Any help will be much appreciated.
-Ravi
# 2  
Old 07-02-2009
Just some hints for now... the blank line is the trigger for record separation (as well as EOF). You can use awk. Collect up the data and when the trigger happens you can use printf in awk to format the output.

I'm just trying to get you to do the work, you'll learn more.

Does that help? (without me or someone writing the code for you)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to identify exact text and then add a blank line above it using sed?

I need to identify the exact text of San Antonio Generator Running in the output my script which lands to a text file. Once SED finds the specific text, I need it to insert one line above the matched text. Here is what I have so far that isn't working all that well for me. Any help would be... (7 Replies)
Discussion started by: jbrass
7 Replies

2. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

3. Shell Programming and Scripting

Formatting File having big single line into 95 Char Per Line

Hi All, I have 4 big files which contains one big line containing formatted character records, I need to format each file in such way that each File will have 95 Characters per line. Last line of each file will have newline character at end. Before:- File Name:- File1.dat 102 121340560... (10 Replies)
Discussion started by: lancesunny
10 Replies

4. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

5. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

6. UNIX for Dummies Questions & Answers

Formatting a line of data into columns

Hi all, I'm a little stuck with a data file I've been collecting data in. The file contains one field of data running continuously down the file and I can't work out how to format the data into three columns. This is a mock up of the file: Each r# is a random number and varies in length, this... (3 Replies)
Discussion started by: nistleloy
3 Replies

7. Shell Programming and Scripting

writing data in a text file at particular line

I need to write value of variable $version at a particular line in a text file. Line number is determined by another variable &line......I don't know how to do it in shell script ... (2 Replies)
Discussion started by: punitpa
2 Replies

8. Shell Programming and Scripting

Reading data from a specific line in a text file

Hello, I have a problem which is giving me headache for days, can some please help. Please see code and text fiel below. Please see text in red for the problem I am facing # Program gets an input x from user while read line ; do echo... (4 Replies)
Discussion started by: jermaine4ever
4 Replies

9. Shell Programming and Scripting

Reading data from a specific line in a text file

hello, I have got the following problem that I am hoping someone can help with please. 1. I have got the following text file (below) , the columns data are 'Test Day', 'Board', 'Betting Number'. TEXT FILE ============================================ 1 3 02-01-27-28-29-30 0 1... (1 Reply)
Discussion started by: jermaine4ever
1 Replies

10. Shell Programming and Scripting

accessing o an exact line in a file

I want to access exact line in a file (sh script) for example I have a variable input and I want to access input.th line in file. for example line 5 or 7. (2 Replies)
Discussion started by: walnut
2 Replies
Login or Register to Ask a Question