On 30-Sep-10 16:46:52, Brett Parker wrote:
On 30 Sep 17:39, Mark Rogers wrote:
On 23/09/10 11:00, Mark Rogers wrote:
I need to go through a text file, and for all lines similar to this: X-Mozilla-Status: 0009 .. I need to unset the 4th bit (so the above becomes 0001).
Just to follow-up on this:
I didn't find a good solution, but did find out that I could remove all the X-Mozilla-Status: lines and Thunderbird was happy with the resulting file, it just had everything marked unread and undeleted.
To remove the lines I used: grep -v 'X-Mozilla-Status:' mailbox > mailbox.tmp mv mailbox.tmp mailbox
Why couldn't you have just done: sed -i -e 's#^X-Mozilla-Status: 0009$#X-Mozilla-Status: 0001#;' mailbox
An inplace replacement of the line with the fixed line.
Cheers,
Brett Parker http://www.sommitrealweird.co.uk/
It seems Mark wants to set bit 4 to 0, presumably whatever the first 3 bits may be. Is that correct?
Also, Mark, how many of the bits would be 1 in this? Since bit 4 can be 1, and bits 1, 2, 3 could be 0 or 1, you could be up to 0015 on those 4 bits alone. Will you be using higher-order bits as well? E.g. with bit 5 in play, you can go up to 0031, with bit 6 up to 0063, etc.
Or is that 4-digit number really in hex? So it could have value 000F, 00BF, 0ABF, ...
In principle, your task can be dome in 'awk', but the details would depend on the answers to these questions!
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) ted.harding@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 30-Sep-10 Time: 18:41:17 ------------------------------ XFMail ------------------------------