Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write a certain hex pattern to a file from bash

I am trying to do some memory tests and am trying to write a certain hex pattern to a regular file from bash. How would I go about doing this without using the xxd or hexdump tool/command?

Thanks, Neco

like image 613
Falcata Avatar asked Jul 13 '26 17:07

Falcata


1 Answers

The simplest thing is probably:

printf '\xde\xad\xbe\xef' > file

but it is often more convenient to do

perl -e 'print pack "H*", "deadbeef"' > file
like image 102
William Pursell Avatar answered Jul 16 '26 08:07

William Pursell