How do I change file headers from the command line?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I have seen and used the GUI hex-editor bless
, to modify bitmaps to match a separate file type (form bmp to srf). My question is how to modify file headers programmatically with the command line. What programs would allow me to make changes to file headers from shell script?
I have looked in synaptic package manager, but I'm new to modifying files in hex. Do bitmaps count as binary files? Where this is a software recommendation request, an acceptable answer would allow me to write, overwrite, or change specific values to specific locations (such as the first 16 bytes of a file), in the command line.
command-line software-recommendation binary
add a comment |Â
up vote
1
down vote
favorite
I have seen and used the GUI hex-editor bless
, to modify bitmaps to match a separate file type (form bmp to srf). My question is how to modify file headers programmatically with the command line. What programs would allow me to make changes to file headers from shell script?
I have looked in synaptic package manager, but I'm new to modifying files in hex. Do bitmaps count as binary files? Where this is a software recommendation request, an acceptable answer would allow me to write, overwrite, or change specific values to specific locations (such as the first 16 bytes of a file), in the command line.
command-line software-recommendation binary
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have seen and used the GUI hex-editor bless
, to modify bitmaps to match a separate file type (form bmp to srf). My question is how to modify file headers programmatically with the command line. What programs would allow me to make changes to file headers from shell script?
I have looked in synaptic package manager, but I'm new to modifying files in hex. Do bitmaps count as binary files? Where this is a software recommendation request, an acceptable answer would allow me to write, overwrite, or change specific values to specific locations (such as the first 16 bytes of a file), in the command line.
command-line software-recommendation binary
I have seen and used the GUI hex-editor bless
, to modify bitmaps to match a separate file type (form bmp to srf). My question is how to modify file headers programmatically with the command line. What programs would allow me to make changes to file headers from shell script?
I have looked in synaptic package manager, but I'm new to modifying files in hex. Do bitmaps count as binary files? Where this is a software recommendation request, an acceptable answer would allow me to write, overwrite, or change specific values to specific locations (such as the first 16 bytes of a file), in the command line.
command-line software-recommendation binary
edited May 13 at 6:11
![](https://i.stack.imgur.com/9L8vd.png?s=32&g=1)
![](https://i.stack.imgur.com/9L8vd.png?s=32&g=1)
dessert
19.6k55594
19.6k55594
asked May 9 at 23:03
![](https://i.stack.imgur.com/nKCzg.png?s=32&g=1)
![](https://i.stack.imgur.com/nKCzg.png?s=32&g=1)
j0h
5,9581348105
5,9581348105
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
xxd
is a very powerful command-line hex editor which allows you to change binary files with a single command line. You can use it this way:
xxd -r -p -o OFFSET <(echo NEW HEX SIGNATURE) FILE # or
echo NEW HEX SIGNATURE | xxd -r -p -o OFFSET - FILE
Let's âÂÂconvertâ 01.png
file to rar format (hex signature 5261 7221 1A07 0000
, offset 0
1):
$ file 01.png
01.png: PNG image data, 1280 x 1024, 8-bit/color RGB, non-interlaced
$ xxd 01.png | head -1
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
$ xxd -r -p -o 0 <(echo 5261 7221 1A07 0000) 01.png
$ file 01.png
01.png: RAR archive data, vdb, os: MS-DOS
$ xxd 01.png | head -1
00000000: 5261 7221 1a07 0000 0000 000d 4948 4452 Rar!........IHDR
See man xxd
for other useful options and lots of helpful examples.
1If the offset is 0
the option -o
can be omitted, I include it here only to show its usage.
If you like it better you can do the truncating with dd
as well, but that seems unnecessarily complicated:
dd conv=notrunc obs=1 if=<(xxd -r -p -o 0 <(echo 5261 7221 1A07 0000)) of=01.png
Further reading (besides usual command-line help):
- Please recommend a hex editor for shell âÂÂ
xxd
answer - Change the header in a huge file without rewriting the whole file
÷ SO - Wikipedia's List of file signatures
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
xxd
is a very powerful command-line hex editor which allows you to change binary files with a single command line. You can use it this way:
xxd -r -p -o OFFSET <(echo NEW HEX SIGNATURE) FILE # or
echo NEW HEX SIGNATURE | xxd -r -p -o OFFSET - FILE
Let's âÂÂconvertâ 01.png
file to rar format (hex signature 5261 7221 1A07 0000
, offset 0
1):
$ file 01.png
01.png: PNG image data, 1280 x 1024, 8-bit/color RGB, non-interlaced
$ xxd 01.png | head -1
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
$ xxd -r -p -o 0 <(echo 5261 7221 1A07 0000) 01.png
$ file 01.png
01.png: RAR archive data, vdb, os: MS-DOS
$ xxd 01.png | head -1
00000000: 5261 7221 1a07 0000 0000 000d 4948 4452 Rar!........IHDR
See man xxd
for other useful options and lots of helpful examples.
1If the offset is 0
the option -o
can be omitted, I include it here only to show its usage.
If you like it better you can do the truncating with dd
as well, but that seems unnecessarily complicated:
dd conv=notrunc obs=1 if=<(xxd -r -p -o 0 <(echo 5261 7221 1A07 0000)) of=01.png
Further reading (besides usual command-line help):
- Please recommend a hex editor for shell âÂÂ
xxd
answer - Change the header in a huge file without rewriting the whole file
÷ SO - Wikipedia's List of file signatures
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
add a comment |Â
up vote
3
down vote
accepted
xxd
is a very powerful command-line hex editor which allows you to change binary files with a single command line. You can use it this way:
xxd -r -p -o OFFSET <(echo NEW HEX SIGNATURE) FILE # or
echo NEW HEX SIGNATURE | xxd -r -p -o OFFSET - FILE
Let's âÂÂconvertâ 01.png
file to rar format (hex signature 5261 7221 1A07 0000
, offset 0
1):
$ file 01.png
01.png: PNG image data, 1280 x 1024, 8-bit/color RGB, non-interlaced
$ xxd 01.png | head -1
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
$ xxd -r -p -o 0 <(echo 5261 7221 1A07 0000) 01.png
$ file 01.png
01.png: RAR archive data, vdb, os: MS-DOS
$ xxd 01.png | head -1
00000000: 5261 7221 1a07 0000 0000 000d 4948 4452 Rar!........IHDR
See man xxd
for other useful options and lots of helpful examples.
1If the offset is 0
the option -o
can be omitted, I include it here only to show its usage.
If you like it better you can do the truncating with dd
as well, but that seems unnecessarily complicated:
dd conv=notrunc obs=1 if=<(xxd -r -p -o 0 <(echo 5261 7221 1A07 0000)) of=01.png
Further reading (besides usual command-line help):
- Please recommend a hex editor for shell âÂÂ
xxd
answer - Change the header in a huge file without rewriting the whole file
÷ SO - Wikipedia's List of file signatures
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
xxd
is a very powerful command-line hex editor which allows you to change binary files with a single command line. You can use it this way:
xxd -r -p -o OFFSET <(echo NEW HEX SIGNATURE) FILE # or
echo NEW HEX SIGNATURE | xxd -r -p -o OFFSET - FILE
Let's âÂÂconvertâ 01.png
file to rar format (hex signature 5261 7221 1A07 0000
, offset 0
1):
$ file 01.png
01.png: PNG image data, 1280 x 1024, 8-bit/color RGB, non-interlaced
$ xxd 01.png | head -1
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
$ xxd -r -p -o 0 <(echo 5261 7221 1A07 0000) 01.png
$ file 01.png
01.png: RAR archive data, vdb, os: MS-DOS
$ xxd 01.png | head -1
00000000: 5261 7221 1a07 0000 0000 000d 4948 4452 Rar!........IHDR
See man xxd
for other useful options and lots of helpful examples.
1If the offset is 0
the option -o
can be omitted, I include it here only to show its usage.
If you like it better you can do the truncating with dd
as well, but that seems unnecessarily complicated:
dd conv=notrunc obs=1 if=<(xxd -r -p -o 0 <(echo 5261 7221 1A07 0000)) of=01.png
Further reading (besides usual command-line help):
- Please recommend a hex editor for shell âÂÂ
xxd
answer - Change the header in a huge file without rewriting the whole file
÷ SO - Wikipedia's List of file signatures
xxd
is a very powerful command-line hex editor which allows you to change binary files with a single command line. You can use it this way:
xxd -r -p -o OFFSET <(echo NEW HEX SIGNATURE) FILE # or
echo NEW HEX SIGNATURE | xxd -r -p -o OFFSET - FILE
Let's âÂÂconvertâ 01.png
file to rar format (hex signature 5261 7221 1A07 0000
, offset 0
1):
$ file 01.png
01.png: PNG image data, 1280 x 1024, 8-bit/color RGB, non-interlaced
$ xxd 01.png | head -1
00000000: 8950 4e47 0d0a 1a0a 0000 000d 4948 4452 .PNG........IHDR
$ xxd -r -p -o 0 <(echo 5261 7221 1A07 0000) 01.png
$ file 01.png
01.png: RAR archive data, vdb, os: MS-DOS
$ xxd 01.png | head -1
00000000: 5261 7221 1a07 0000 0000 000d 4948 4452 Rar!........IHDR
See man xxd
for other useful options and lots of helpful examples.
1If the offset is 0
the option -o
can be omitted, I include it here only to show its usage.
If you like it better you can do the truncating with dd
as well, but that seems unnecessarily complicated:
dd conv=notrunc obs=1 if=<(xxd -r -p -o 0 <(echo 5261 7221 1A07 0000)) of=01.png
Further reading (besides usual command-line help):
- Please recommend a hex editor for shell âÂÂ
xxd
answer - Change the header in a huge file without rewriting the whole file
÷ SO - Wikipedia's List of file signatures
edited May 10 at 7:52
answered May 10 at 7:45
![](https://i.stack.imgur.com/9L8vd.png?s=32&g=1)
![](https://i.stack.imgur.com/9L8vd.png?s=32&g=1)
dessert
19.6k55594
19.6k55594
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
add a comment |Â
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
This worked, for me. I figured out the magic number from the files on my GPS, and changed the files I generated to match those identities.
â j0h
May 12 at 23:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1034267%2fhow-do-i-change-file-headers-from-the-command-line%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password