I have a tar gz file. Inside the file are other directories and gz files and I am trying to recursively grep for a string. I have tried zgrep but the string I am searching for is not outputted even though I know it is there. What would be the command to do this?. The gz files inside the tar.gz files are *xml.gz files about 10k files.
Related
I'm trying to extract a tar file where the contents of its dirs may change from time to time. I'd like to be able to extract the tar file regardless of what the root dir is. For example:
tar path and filename = /home/user/archive1.tar
If I run tar zxvf /home/user/archive1.tar -C /home/user then it's all extracted to /home/user/archive1 including any subdirs. The problem is that another tar file may extract to a different dir like /home/user/archive070320
What I need is to always extract to /home/user/myowndir and any files and subdirs that are in the tar file go to this dir. So even though inside the tar file it has a root dir of archive1 or archive0730320 or whatever, I'd like to replace that target rootdir with my own static root dir such as 'myowndir'
Also, it would really help if this could be done on one line and preferrably work on any Linux as well as AIX.
I have a tr.gz backup file, and I need to delete some file inside of this tar.gz file without extract the tar.gz file.
Is there any solution (command line or software) in windows?
It is not possible to remove the file from tar, but you can exclude a file by the following command
tar -zxvf file.tar.gz --exclude "file_to_exclude"
or
take a backup too and proceed
OR
tar -cvf files.tar --remove-files my_directory
I'm trying to extract files from a tar file on a windows 7 machine using 7Zip's 7za.exe the command line. The file is 700GB and I only need a specific subdirectory. This should be possible using the following command.
7za x -r test.zip folder\subfolder
Running this on a test file (test.zip) does what is expected, i.e. it extracts all (sub)files from the folder\subfolder in the zip file. However, for the tar file, it doesn't work. I think it is related to a difference in file listings, as exemplified below.
7za l test.zip
produces:
folder
folder\subfolder
folder\subfolder\on_ADJ.png
While
7za l 20150602.tar
produces (excerpt):
.\Corpus
.\Corpus\DOC
.\Corpus\DOC\manual.pdf
Parallel to the first command, I tried using the following command.
7za x -r 20150602.tar .\Corpus\DOC
However, it doesn't work. Working within quotes (".\Corpus\DOC") or without .\ doesn't work either and 7Zip produces the following error.
Cannot use absolute pathnames for this command
Am I right that the tar file has absolute paths in it? If so, how could I solve this problem without having to extract the whole file?
I would like to do a grep inside my zip file.
While i was trying with zgrep it doesn't work because when I tried with command
File
It returns the file as PKZIP: compressed archive
Zgrep doesn't work under pkzip files it seems.
Can any one help me on this?
One (heavy) method, if you have multiple grep to do, is to mount your zip with fuse-zip and grep files in the mounted directory.
How do I list only the contents of a tar file that are actual files or links to files and not directories?
I ask this because I want to take the tar -tf of an archive then retrieve the files in it from another directory.
One option (assuming you are on a *NIX system) is to parse and filter the output from a verbose listing
tar -tvf abc.tar | awk '!/^d/ {print $NF}'
Although this is fraught with all the perils of parsing ls output