Question : File formatting with AWK unix command??

Gurus,

I'm having an issue formatting a file with the AWK command. It adds the formatting I need but strips out the rest of the data. Would someone please tell me how to fix this issue?

Examples:

Data before formatting:

ProdRX|Day|Color|Category|SubCategory|Theme|Pages|PagePos
a345|Su|Red|001|a001|good|8|1
a346|Sa|Blue|002|a002|better|9|2
a347|Fr|Brown|003|a003|best|10|3

Data after formatting: -
awk -F"|" '{print "\\Category=" $1 "\\SubCategory=" $2 "\\Theme=" $3 "\\Pages=" $4 "\\PagePos=" $5 "|" }' inputfile

Category|SubCategory|Theme|Pages|PagePos
Category=001\SubCategory=a001\Theme=good\Pages=8\PagePos=1|
Category=002\SubCategory=a002\Theme=better\Pages=9\PagePos=2|
Category=003\SubCategory=a003\Theme=best\Pages=10\PagePos=3|

As you can see ... It completely striped out the first 3 column data!

What I need the data to look like:
ProdRX|Day|Color|Category|SubCategory|Theme|Pages|PagePos
a345|Su|Red|Category=001\SubCategory=a001\Theme=good\Pages=8\PagePos=1|
a346|Sa|Blue|Category=002\SubCategory=a002\Theme=better\Pages=9\PagePos=2|
a347|Fr|Brown|Category=003\SubCategory=a003\Theme=best\Pages=10\PagePos=3|

How do I get the data formatted like my last example?

Thanks!

Answer : File formatting with AWK unix command??

>>What's the best way to modify bitfields used for hardware register
is to not use bitfields.

>> I want to modify 'DR' (bits 3,2)
I don't see how that matches your bitfields DR
==============

See if this is what you are driving for:

In any case, it seems that you want your UpdateReg() function to be general enough to handle any scenario.

UpdateReg( char mask, char newPattern );
         where mask is a set of arbitrarily placed bits that will clear
I'm assuming that you can read the register in a temp variable, and then manipulate it, and finally write it back to the HW register. (This isn't always true, since sometimes reading the HW register changes the value.)

So the mask is adapted to first clear the corresponding bits in the temp variable (after you read the HW register). Then, using the mask again with the newPattern, I now have the valid set of bits (or 0's) to or into the temp register. Then write the temp back to the HW.
Random Solutions  
 
programming4us programming4us