Исправление нескольких строк в двоичном файле

Эта реализация scryptсоответствует вашим требованиям, см.https://github.com/jkalbhenn/scrypt

scrypt-kdf [options...] password [salt N r p size salt-size]
                         string string integer integer integer integer integer]
options
  -b|--base91-input  password and salt arguments are base91 encoded
  -c|--check hash  test if hash is derived from a password
  -h|--help  display this text and exit
  -p|--crypt  use unix crypt format
  -v|--version  output version information and exit

1
13.10.2020, 08:20
1 ответ

Просто используйте perl, который отлично работает с бинарными файлами:

perl -pi -e 's/DC-GX850/DMC-GX95/g'./*.RW2

Или если вы хотите произвести замену только в первых 1000 байтах файлов:

perl -pi -e '
  BEGIN {$/ = \1000} # records are 1000 byte blocks instead of lines
  s/DC-GX850/DMC-GX95/g if $. == 1; # substitute in first record only
  close ARGV if eof # to reset $. between files'./*.RW2

С помощью -iфайлы изменяются на месте (фактически, заменяются модифицированной копией ), изменяются на -i.orig, чтобы сохранить оригинал с расширением .orig.

2
18.03.2021, 22:57

Теги

Похожие вопросы