简体   繁体   中英

Decompressor using Shell Scripting

Am trying to make a compressor and decompressor on top of gzip. In my compressor after adding my logic I pax the files and then zip the result and save it as *.abc

pax -w $allfiles > $paxfile  

gzip $paxfile > $zippedfile

In decompressor I have to start by unzipping it, since unzip doesn't work on *.abc I renamed file to file.gz and then stored the result in file.pax . I try to pax read it then.. Am stuck here

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

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

please help. I am clueless about what am doing wrong. Error I get is

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 > 

Am I doing something wrong while pax -r?

You can avoid creating intermediate files and achieve what you want (I guess) with the following.

To Compress:

pax -w $allfiles | gzip - > $zippedfile

with the "-" standing for "read from standard input (ie, the pipe).

Then to decompress:

gunzip -c -d $ip | pax -r

with the "-c" standing for "write to standard output", "-d" for "decompress" (maybe not needed).

Hi Well I solved my problem. There was a problem with the filenames and extensions. I wasn't extracting them and conveying to *.gz properly. I changed and modified those so now I unzip the correct file and then pipe it pax read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM