incrementing lines in the file & format output.

Hi All,
I need read the file and out put format as below using ksh, I wrote below script its keep on repeating first line in the file.
may i know the best way to get the below out put while incrementing line in the file.

cat b.txt |awk '{print $0}' |while read line
do
aa=`cat $line |head -1 |sort -n`
bb=`cat b.txt |head -2 |sort -n |head -1`
echo $aa $bb
done

in my file

rs6qditim06_A_DMX3_7bB
c0:50:76:03:06:0e:00:08
rs6qditim07_B_DMX3_7bB
c0:50:76:03:06:0e:00:0a

output need to format

rs6qditim06_A_DMX3_7bB  c0:50:76:03:06:0e:00:08
rs6qditim07_B_DMX3_7bB  c0:50:76:03:06:0e:00:0a

May thanks in advance.

Thx!
Ashan

Is this what you want:

paste -d' ' - - < Inp_File

How do i increment each line in the file and read, If can assign to two variables while increment line then i can get the output I need.

cat b.txt |paste -s -d " " - > c.txt
output
rs6qditim06_A_DMX3_7bB c0:50:76:03:06:0e:00:08 fra1bvch03p_B_DMX3_8bB c0:50:76:03:06:0e:00:0a

I need the out like below
rs6qditim06_A_DMX3_7bB c0:50:76:03:06:0e:00:08
fra1bvch03p_B_DMX3_8bB c0:50:76:03:06:0e:00:0a

I really didn't understand your script but if you just want to change every 1, 3, 5, etc. newlines to spaces, then pipe it to

sed  'N; s/\n/ /'

Txh! it works for me. now i can fix my script.

cat b.txt |sed 'N; s/\n/ /'
rs6qditim06_A_DMX3_7bB c0:50:76:03:06:0e:00:08
fra1bvch03p_B_DMX3_8bB c0:50:76:03:06:0e:00:0a

Sir, make sure you use EXACTLY the proposed solution:

paste -d' ' - - < Inp_File

I never suggested you use:

cat b.txt |paste -s -d " "  - > c.txt

The solution:

sed  'N; s/\n/ /'

does not output the last line for an odd number of lines file. Example:

Line1
Line2
Line3

The output will be:

Line1 Line2

The last record "Line3" will not be displayed.

If you want to use "sed", here is a working solution:

sed '$!N;s/\n/ /' 

how do i incrementing lines in any txt file and print.

What do you mean?