我有一个输出存储在hashes_output.txt。此输出来自此命令:
cat hashes.txt |base58 |rev|compress |hexdump
.
问题是我没有这个文件hashes.txt,我的目标是找回它。
所以,我试过了:
cat hashes_output.txt |hexdump|rev|base58 -d
=> 它给了我: subsection not found...
cat hashes_output.txt |hexdump|uncompress|rev|base58 -d
=> 它给了我:gzip: stdin: 不是 gzip 格式...
所以我完成了:
gzip hashes_output.txt
(生成我hashes_output.txt.gz)然后:cat hashes_output.txt.gz |xxd -r|uncompress|rev|base58 -d
。我仍然有:gzip: stdin: 不是 gzip 格式
但如果我这样做
file hashes_output.txt.gz
=> hashes_output.txt.gz:gzip 压缩数据,是“hashes_output.txt”,最后修改时间:2023 年 3 月 8 日星期三 18:37:07,来自 Unix,原始大小模 2^32 473.
它说它是 gzip 格式,有人看到了吗,为什么那不起作用??我很困惑
解决方案
假设文件最初是使用创建的:
cat hashes.txt |base58 |rev|compress |hexdump > hashes_output.txt
假设正在使用的系统是小端,那么反转它的方法是:
sed 's/ \(..\)\(..\)/ \2\1/g;$d' hashes_output.txt | xxd -r | compress -d | rev | base58 -d
更多细节
为你复制这个时,我遇到的第一个问题是如果你的系统是小端,
xxd -r
不起作用:
:~$ cat hashes.txt
Hello
:~$ cat hashes.txt | hexdump > test.txt
:~$ xxd -r test.txt
eHll
o
谢天谢地,这个问题已经解决了这里,它展示了如何使用
sed
成功地逆转hexdump
:~$ sed 's/ \(..\)\(..\)/ \2\1/g;$d' test.txt | xxd -r
Hello
下一个问题是我最初的建议是使用
uncompress
来反转 compress
因为它给出了与您收到的 gzip
相同的错误:
:~$ cat hashes.txt | compress > comp
:~$ uncompress comp
/usr/bin/uncompress: 57: exec: gzip: Exec format error
快速 rtfm 帮助解决了这个问题:
:~$ compress -h
Usage: compress [-dfhvcVr] [-b maxbits] [--] [file ...]
-d If given, decompression is done instead.
:~$ cat comp | compress -d > uncomp
:~$ cat uncomp
Hello