linux - 使用 Shell 脚本解压

标签 linux shell

我正在尝试在 gzip 之上制作压缩器和解压缩器。在我的压缩器中添加逻辑后,我对文件进行 pax,然后压缩结果并将其另存为 *.abc

pax -w $allfiles > $paxfile  

gzip $paxfile > $zippedfile

在解压缩器中,我必须首先解压缩它,因为解压缩不适用于 *.abc 我将文件重命名为 file.gz ,然后将结果存储在 file.pax 中。然后我尝试着阅读它。我被困在这里

i=$(echo $filename | cut -d'.' -f1)
echo $i
ip=$i.gz
mv "$filename" "$ip"
op=$i.pax

gunzip -f < $ip > $op | pax -r 

请帮忙。我对做错了什么一无所知。我得到的错误是

pax: End of archive volume 1 reached
ATTENTION! pax archive volume change required.
Ready for archive volume: 1
Input archive name or "." to quit pax.
Archive name > 

我在 pax -r 时做错了什么吗?

最佳答案

您可以避免创建中间文件并通过以下方式实现您想要的(我猜)。

压缩:

pax -w $allfiles | gzip - > $zippedfile

其中“-”代表“从标准输入(即管道)读取。

然后解压:

gunzip -c -d $ip | pax -r

“-c”代表“写入标准输出”,“-d”代表“解压缩”(可能不需要)。

关于linux - 使用 Shell 脚本解压,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19747381/

相关文章:

linux - 如何使用 bash 查找某个文件中的哪些行不是由另一个文件中的行开始的?

linux - shell 脚本中的命令 'find with -exec'

linux - 将 euid 和 egid 转换为用户名和组名

linux - 定时任务错误: "/tmp/crontab.calJpk":5: bad day-of-month

linux - MFC 类似 Linux 的易于使用的工具

mysql - shell脚本中mysql存储过程的关联数组

c++ - 使用Linux pread可以避免 “unavailability of data for reading written by a different thread”吗?

python - ftplib.error_perm : 553 Could not create file. (Python 2.4.4)

一条命令中的Linux shell单引号和双引号

mysql - 需要在SHELL的MySQL输出中添加分隔符