LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gzip -cr (https://www.linuxquestions.org/questions/linux-newbie-8/gzip-cr-946958/)

BalajiGovardhan 05-26-2012 04:53 AM

gzip -cr
 
Hi,
tried the following


drwx------ 6 oracle oinstall 4.0K May 26 15:12 .
[oracle@INPRJ-ARMCSG01 ~]$ mkdir test_dir
[oracle@INPRJ-ARMCSG01 ~]$ cd test_dir
[oracle@INPRJ-ARMCSG01 test_dir]$ touch abc.txt
[oracle@INPRJ-ARMCSG01 test_dir]$ touch def.txt
[oracle@INPRJ-ARMCSG01 test_dir]$ cd ..
[oracle@INPRJ-ARMCSG01 ~]$ gzip -cr test_dir > test_dir.gz
[oracle@INPRJ-ARMCSG01 ~]$ ls -lhtra
-rw------- 1 oracle oinstall 179 Apr 27 20:19 .Xauthority
-rw------- 1 oracle oinstall 35 May 26 10:43 .lesshst
-rw------- 1 oracle oinstall 14K May 26 13:17 .bash_history
drwxr-xr-x 2 oracle oinstall 4.0K May 26 15:22 test_dir
-rw-r--r-- 1 oracle oinstall 56 May 26 15:22 test_dir.gz
drwx------ 7 oracle oinstall 4.0K May 26 15:22 .
[oracle@INPRJ-ARMCSG01 ~]$ rm -rf test_dir
[oracle@INPRJ-ARMCSG01 ~]$ ls -lhtra
-rw------- 1 oracle oinstall 179 Apr 27 20:19 .Xauthority
-rw------- 1 oracle oinstall 35 May 26 10:43 .lesshst
-rw------- 1 oracle oinstall 14K May 26 13:17 .bash_history
-rw-r--r-- 1 oracle oinstall 56 May 26 15:22 test_dir.gz
drwx------ 6 oracle oinstall 4.0K May 26 15:22 .

Now when I try to uncompress this file it does not take the form of the folder.

tried gunzip -cd test_dir.gz > test_dir

tried gunzip -d test_dir.gz
- no results.

Need help.

pixellany 05-26-2012 05:37 AM

From the gzip man page:
Code:

-r --recursive
              Travel  the  directory  structure recursively. If any of the file names specified on the command
              line are directories, gzip will descend into the directory and compress all the files  it  finds
              there (or decompress them in the case of gunzip ).

gzip -r dirname compresses each file that it finds in dirname, but it does not do anything to dirname

This does not work:
Code:

gzip -r testdir > newfile
the gzip -r command compresses all the file that it finds in testdir, but does not write anything to newfile.

I think you need tar to do what you want----eg
Code:

tar -czf testdir.cmp testdir  ##compresses testdir and its contents into "testdir.cmp"
tar -xzf testdir.cmp          ##recreates testdir and its contents



All times are GMT -5. The time now is 09:00 PM.