How to get only the first ten bytes of a binary file

前端 未结 3 722
孤独总比滥情好
孤独总比滥情好 2021-01-31 13:11

I am writing a bash script that needs to get the header (first 10 bytes) of a file and then in another section get everything except the first 10 bytes. These are binary files

相关标签:
3条回答
  • 2021-01-31 13:38

    To get the first 10 bytes, as noted already:

    head -c 10
    

    To get all but the first 10 bytes (at least with GNU tail):

    tail -c+11
    
    0 讨论(0)
  • 2021-01-31 13:39

    You can use the dd command to copy an arbitrary number of bytes from a binary file.

    dd if=infile of=outfile1 bs=10 count=1
    dd if=infile of=outfile2 bs=10 skip=1
    
    0 讨论(0)
  • 2021-01-31 13:57

    head -c 10 does the right thing here.

    0 讨论(0)
提交回复
热议问题