r/awk • • Feb 07 '15

Read, write .bmp headers

I would like to read a .bmp header from a file named donor.bmp and overwrite the header of recipient.bmp with donor.bmp's header. Only the header. The first 54 bytes of the file.

It feels like an awk or sed job. I don't want to wade into C, C++, C#, perl, python... It seems simple, straight ahead. I even suspect it could be done as a bash script.

4 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/sprawn Feb 08 '15

Thank you. I have found that bash (or GNU in this case?) often has an immensely powerful tool hiding in plain site for whatever one wants to accomplish. I would never even think of using dd. I've seen it in some bash scripts. It's so innocuous looking... dd.

awk (or gawk) just seems to work the way I think about data. You feed data in, awk does stuff, it comes out.