Bit Mapping

Hi All,

I am working on the Scenario where i need compare the integer value with other using bit mapping.

input file,

1,4,5,4
1,2,4,6
2,3,4,4

like i have many fields.

Script :

i need to filter hte field one value "1" and field 3 value "4" and Filed 4 i need to do the Bitwise operation. check the value with 2.

i managed to make a awk command for all other operation except the Bitwise condition ,

please help me

Br,
bala

Please give a sample of input and output file you expect, maybe people will then be able to help you

Input File :

12,706,706,NULL,0.000000000000000e+00,0,0,0,0,0,0,0,0,0,0,0,0,16384,0,0,0,0,0
12,706,706,NULL,0.000000000000000e+00,0,0,0,0,0,0,0,0,0,0,0,0,536870912,0,0,0,0,0

i need to filter the records based on the below condition

  1. Field 1 : Should be equal to 706

  2. Field 18 : should be equal to 16384 (i need check this candition using the Bitwise operator)

br,
bala

what do you mean by filter ?
extract those ? or filter them out ?

you need them to meet both condition 1) AND 2) or just one of them if 1) OR 2) then print|filter out ????

---------- Post updated at 12:21 PM ---------- Previous update was at 12:12 PM ----------

awk -F, '($18==16384) && ($1==706)' inputfile

??
in your exemple none of the record have a first field with value 706 ... did you mean field 2 or field 3 instead ?

while read -r l
 do
    if [ $(echo "$l" | cut -d',' -f2 ) -eq 706 ] && [ $(echo "$l" | cut -d',' -f18 ) -eq 16384 ] ; then
     echo "$l"
    fi
 done <infle1

what do you mean by filter ?
extract those ? or filter them out ?

I want Extract those records

you need them to meet both condition 1) AND 2) or just one of them if 1) OR 2) then print|filter out ????

both the Condition should meet
---------- Post updated at 12:21 PM ---------- Previous update was at 12:12 PM ----------

awk -F, '($18==16384) && ($1==706)' inputfile

Field 18 should be checked with Bitwise operator (want to match the Bitwise AND)
??
in your exemple none of the record have a first field with value 706 ... did you mean field 2 or field 3 instead ?
Reply With Quote Multi-Quote This Message Quick reply to this message Thanks