0

I created the compressed tar file using the below command.

find /app/jboss -not -name "*.err" -not -name "*.log" | cpio -o | gzip >/app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz

I got the compressed file here

[user1@myhost test]$ ls -ltr /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz
-rwxrwxr-x 1 user1 mygrp 363997224 Aug 18 16:08 /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz

I want to extract the /app/jboss directory under /app/patchbkp/test so i get /app/patchbkp/test/app/jboss/.......; thus i try the below command.

cd /app/patchbkp/test/
zcat /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz | cpio -i

But this does not generate any files under /app/patchbkp/test

I get permission denied error when i try gunzip /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz

Can you please guide me as to how can I extract the tar compressed /app/jboss under /app/patchbkp/test directory?

0

1 Answer 1

1

The first command creates a compressed cpio-format archive with absolute filenames. This means that when you extract the files, they will be placed in those absolute places

Note that cpio -o writes a cpio-format archive, not a tar-format one. You should use cpio -o -H tar for a tar-format file.

Your extract command will work, but only by writing the files to the absolute locations on the filesystem. You can see what would happen by first listing the file with the -t flag

zcat /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz | cpio -it

I would instead recommend these variants of your commands

( cd / && find app/jboss -not -name "*.err" -not -name "*.log" | cpio -o -H tar ) | gzip >/app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz

or even use GNU tar directly if you have it

tar -C / -f /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz -cv --exclude '*.log' --exclude '*.err' app/jboss
2
  • find does not support a primary called -not.
    – schily
    Oct 10, 2020 at 21:44
  • 1
    @schily it's a GNU extension. The OP used it, so I continued with their original command as a starting point
    – roaima
    Oct 10, 2020 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.