I think you have a cut and paste issue with your sample data. Going on what I believe you meant, this will read two lines from stdin and output the 'words' from each line using the indicated bit masking:
---------- Post updated at 21:07 ---------- Previous update was at 21:03 ----------
From your original post:
Shouldn't the two values in the file have been
000001ac
f7c392ac
given the output you listed, or the output should have been:
000001ac 0 428
ca85210e 207380 132 1 1 1 0
---------- Post updated at 21:16 ---------- Previous update was at 21:07 ----------
And one more note about the solution I posted. I originally read into word and assigned 0x to the variable so that I wouldn't need to prefix $word in each expression. This resulted in interesting behaviour in ksh -- bash seemed to get it right both ways. I need to test with a current build of ksh -- the most recent build I have access to here is 2011/02.
It prints the first output line incorrectly, but the second is correct. Don't know if anybody wants to verify or offer an explanation, but it would be appreciated.
Yes, the output was posted incorrectly. Sorry about that. I must have been in a rush. Forgot to cut and paste the correct hex words in the output.
It should be: