sch*_*ily 36
您不能这样做,因为对于这样的转换,您需要知道二进制内容的含义。
例如,如果二进制文件中有一个字符串,则不得对其进行转换,并且 4 字节整数可能需要与两字节整数不同的处理。
换句话说,对于字节顺序转换,您需要一个数据类型描述。
roa*_*ima 34
您可以使用dd
. 够了吗?如果没有,请更新您的问题以提供输入文件和预期输出文件的示例。
echo hello >infile
dd conv=swab <infile >outfile
hex infile
0000 68 65 6c 6c 6f 0a hello.
hex outfile
0000 65 68 6c 6c 0a 6f ehll.o
Run Code Online (Sandbox Code Playgroud)
为了更改文件字节顺序,假设字(32 位)大小,这 1 行应该适合您:
hexdump -v -e '1/4 "%08x"' -e '"\n"' input_file | xxd -r -p > output_file
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
28313 次 |
最近记录: |