Searching a Tar file


Results 1 to 3 of 3

Thread: Searching a Tar file

  1. #1
    Join Date
    Jul 2010
    Posts
    4

    Searching a Tar file

    Hey,

    I am trying to cat/grep a file in a tar file. I know there has to be a way to do this. I have tried the tar tvf, but that just list the files.

    Thanks for any help you can give.

  2. #2
    Join Date
    Jul 2010
    Posts
    4
    It is a Solaris 9 box

  3. #3
    Join Date
    Jul 2001
    Location
    UK
    Posts
    316
    I think what you need to do is extract the file to stdout and pipe it to the command you want, something like
    Code:
    tar xfO [tar file] [desired file]|grep [pattern]
    where [desired file] is the path and filename within the tar file, which must be written exactly as it appears in the list you got from tar tvf.

    If you leave off the |grep [pattern] then it'll just dump the file to stdout, as if you'd used cat on a normal file.
    We are free to think. We are free to plan. And we are free to do. But once an action has been taken, we are never free from its consequences.
    --Russel M. Nelson, apostle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •