Hi,
I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date?
Thanks!
Hi,
I would like to ask if there is a way to search for a file inside a .tar.gz file without extracting it? If there is, is there a way to search for that file by date?
Thanks!
you can view the list of files using from tar.gz
tar -tvzf file.tar.gz
Apply grep command on the o/p of above command to find out particular file
it says that "z" is not a recognized flag.
tar: Not a recognized flag: z
Usage: tar -{c|r|t|u|x} [ -BdDEFhilmopRUsvwZ ] [ -Number ] [ -f TarFil e ]
[ -b Blocks ] [ -S [ Feet ] | [ Feet@Density ] | [ Blocksb ] ]
[ -L InputList ] [-X ExcludeFile] [ -N Blocks ] [ -C Directory ] File ...
Usage: tar {c|r|t|u|x} [ bBdDEfFhilLXmNopRsSUvwZ[0-9] ] ]
[ Blocks ] [ TarFile ] [ InputList ] [ ExcludeFile ]
[ [ Feet ] | [ Feet@Density ] | [ Blocksb ] ] [-C Directory ] File ...
Try
gunzip -c file.tar.gz | tar tvf -
BTW, the content of the files inside this archive contains the date the file was created.
what if I have to search for a file/s inside it by date?
gunzip -c file.tar.gz | tar tvf - | grep filename
How do I follow this up to search the file/s with a specific filename with a specific date that file was created?
And also, I know this is incorrect, but how do I make this right:
gunzip -c file.tar.gz | tar tvf - | grep filename -exec cp {} /home/myhome \;
Thanks!