I have a file (tmp1) which is a list of numbers which are in the following format:
4373610497
4416339969
4426498049
4435738625
Each 64 bit number here is actually made up of multiple 16 bit fields which have the numbers I'm interested in.
For Eg (and only showing the 48 bits that matter here):
4435738625 = 0000000000000001 0000100001100100 0000000000000001
And the numbers I want are:
a= 0000000000000001 = 1
b= 0000100001100100 = 2148
c= 0000000000000001 = 1
This is the code I'm using to do this right now - but it's painfully slow. The input file contains between 500K and 1 million lines, so I'm trying to look for ways to do this faster or more efficiently.
while read line; do
a=$((((line >> 32)) & 65535));
b=$((((line >> 16)) & 65535));
c=$((line & 65535));
printf "$a $b $c\n" >>tmp2
done <tmp1
I need to run this on a FreeBSD machine - so I can't use gawk. And awk does not seem to allow bit-wise operations.