concate the record

how i can bring this file into three records
in my sample text file there are thre records new records always
start with Data File

==================================================
samle file

=================================================

Data File: /opt/oracle/dc/data/diff/tsn/rk.txt
664632 Rows successfully loaded.
0 Rows not loaded due to data errors.
417 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Data File: /opt/oracle/dc/data/diff/jkt/rk.txt
2531666 Rows successfully loaded.
0 Rows not loaded due to data errors.
141925 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Data File: /opt/oracle/dc/data/diff/del/rk.txt
ORA-01401: inserted value too large for column
ORA-01400: cannot insert NULL into (HBL)
6931772 Rows successfully loaded.
2 Rows not loaded due to data errors.
1905 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.

i need the output like

first record look like below(in one line)

Data File: /opt/oracle/dc/data/diff/tsn/rk.txt 664632 Rows successfully loaded. 0 Rows not loaded due to data errors. 417 Rows not loaded because all WHEN clauses were failed. 0 Rows not loaded because all fields were null.

awk '
   /^Data File: / { if (NR > 1) print(""); }
   { printf("%s ", $0); }
   END { print(""); }
' input_file

Not tested but try this:

awk ' 
{

while ( /Data File/ ~ Nextline )
{
getline Nextline
$0= $0 Nextline
}

print $0

}' filename

HI Rob and Ahmed
Thanks for your help it works

rob how i can add delimeter in the record

for example in the same file once i bring the record in one line
i need delimiter(any symbol like ; or |) insidethe record

Data File: /opt/rsi/rdc/procarsdata/auadlpiii.txt | 121444 Rows successfully loaded.

here i put delimite | (pipe symbol)

rds
a.k

awk '
   /^Data File: / {
      sep="|";
      if (NR > 1) {
         print("");
      }
   }

   {
     printf("%s%s", $0, sep);
     sep=" ";
   }

   END {
      print("");
   }
' input_file

HI robotronic
Thanks for your reply it works for first value next value no pipe symbol
it looks as follows

Data File: /opt/rsi/rdc/procarsdata/auadlpiii.txt| 121715 Rows successfully loaded. 0 Rows not loaded due to

in my expample i mention one record have more than five rows all these
rows need to be seperated by | symbol

this script put one pipe symbol , in above record the pipe symbol need to come after loaded

record look like

Data File: /opt/rsi/rdc/procarsdata/auadlpiii.txt
121715 Rows successfully loaded.
0 Rows not loaded due to data errors.

the result shoul look like

Data File: /opt/rsi/rdc/procarsdata/auadlpiii.txt | 121715 Rows successfully loaded. | 0 Rows not loaded due to data errors.

but the current script shwo the output as

Data File: /opt/rsi/rdc/procarsdata/auadlpiii.txt | 121715 Rows successfully loaded. 0 Rows not loaded due to data errors.

best rds

Try this:

awk ' BEGIN {  ORS="" }
   /^Data File: / { if (NR > 1) print("\n"); }
{ print $0"|" }
 
' filename

I know that my script behaves like you described, I've just followed literally the rules you told me in the 4th message :slight_smile:

Anyway, ahmed's code works fine for your purpose.