mar*_*ark 13 linux command-line
我想在二进制文件的开头添加 8 个字节的数据。
是否有针对此的 Linux 命令?
gar*_*ohn 21
这是一种方法。
printf "\x68\x65\x6c\x6c\x6f\x20\x77\x6f" | cat - oldfile > newfile
Run Code Online (Sandbox Code Playgroud)
to 的参数printf是 8 个字节的十六进制序列。只需将我使用的值(即 ASCII 字符“hello wo”)替换为您的值。
它不是“那个”命令,而是“一堆命令”(按照古老的 UNIX 传统):
或者:
% echo -n "12345689" > new_file
% cat original >> new_file
% mv new_file original
Run Code Online (Sandbox Code Playgroud)
或者,如果您需要从其他地方读取 8 个字节:
% dd if=inputstream of=new_file bs=1 count=8
Run Code Online (Sandbox Code Playgroud)
然后继续如上所述。
| 归档时间: |
|
| 查看次数: |
21621 次 |
| 最近记录: |