Merging lines of an output file. (newbie)

Merging lines of an output file. (newbie)

Post by Darren Wa » Thu, 16 Aug 2001 19:31:14



I've got the following result from a script that I have written which
is analysing some log files;

1 Date1
2 Data1
1 Date2
2 Data2

I want the file to read;

Date1 Data1
Date2 Data2

In logic what I'm want to do is remove all instnaces of a line break
which are followed by "2". I believe I'll need to use the 'sed'
command?

Any help apreciated.

Darren

 
 
 

Merging lines of an output file. (newbie)

Post by Dave Granti » Fri, 17 Aug 2001 09:44:22




Quote:> I've got the following result from a script that I have written which
> is analysing some log files;

> 1 Date1
> 2 Data1
> 1 Date2
> 2 Data2

> I want the file to read;

> Date1 Data1
> Date2 Data2

> In logic what I'm want to do is remove all instnaces of a line break
> which are followed by "2". I believe I'll need to use the 'sed'
> command?

Here's a *:
 awk '/^1/{ printf("%s ", substr($0,3)) } /^2/{ printf("%s\n",
substr($0,3))) } ' yourfile.

Cheers!
Dave

+---------------------+---------------+


+---------------------+---------------+

 
 
 

1. Newbie on Unix, need to merge lines in a file.

Hi there,

I need to write a script on Unix to merge some lines of a file.

The input file will be something like :

EXEC SQL.......
      COL1 = :FRED
      COL2=  :VAR1
      .SUBVAR AND
      COL3 = :VAR2
END-EXEC

I need to get to :

EXEC SQL.......
      COL1 = :FRED
      COL2=  
      :VAR1.SUBVAR AND
      COL3 = :VAR2
END-EXEC

So if there is a line starting with a dot and the previous line
contains ':', then I need to merge the 2 lines together after the ':'

Thanks for your help.

Regards, Manuel.

2. Asus K8N-E Deluxe: Jerry-rig an S/PDIF In?

3. Merging files together line by line or by comparison

4. soft linking prior to using

5. Perl script log file output has duplicate copies of output lines

6. Subdomains for Analog 1.92beta

7. awk-outputting input line in specified output line

8. Laptop printing with Apple LaserWriter II NTX??

9. ERROR: Open Output File, DETAIL: 0 FILE: SystemCmd.cc LINE 484

10. Sed: merging lines recursively depending on line pattern

11. want a single command to merge consecutive 2 lines in a data file

12. how to merge multiple lines into one line

13. Merging every other line in a file