How to write a binary file using Bash?

后端 未结 6 1838
迷失自我
迷失自我 2021-02-05 05:46

My problem is that I need to create a file with this exact bytes: 48, 00, 49, 00.

I cannot use C, perl, other scripting language (the target is an embedded

6条回答
  •  盖世英雄少女心
    2021-02-05 06:29

    I don't know what's in busybox, but this might work because printf is smaller than awk.

    $ printf "%c%c%c%c" 48 0 49 0 | hexdump
    

    This is the output:

    $ printf "%c" 1 | hexdump
    0000000 0031                    
    

提交回复
热议问题