I wanna do some bitwise operations (for example xor two files) on files in Linux , and I have no idea how I can do that. Is there any command for that or not?
any help will be appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can map the file with mmap, apply bitwise operations on the mapped memory, and close it.
Alternatively, reading chunks into a buffer, applying the operation on the buffer, and writing out the buffer works too.
Here’s an example (C, not C++; since everything but the error handlings is the same) that inverts all bits: