![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Single line file editing command? | gator76 | Shell Programming and Scripting | 1 | 04-03-2008 11:09 AM |
| tar: extract single file to different filepath | littleIdiot | Shell Programming and Scripting | 3 | 02-29-2008 09:41 AM |
| how to unzip and extract tar file in single command | darkrainbow | UNIX for Advanced & Expert Users | 6 | 02-28-2008 08:18 PM |
| extract bulk emails into a single flat file | Amruta Pitkar | Shell Programming and Scripting | 1 | 01-21-2007 06:37 PM |
| Extract first file only from ls command | prekida | Shell Programming and Scripting | 4 | 07-26-2005 05:46 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
tar command help -- extract single file
Hi,
I want to view/display the contents of one file in tar file. For example if the tar file is sam.tar.gz and one of the file inside is E1.txt, how do i view the contents of this E1.txt file. Olso if I want to extract the E1.txt file only from sam.tar.gz how can i do that. Thanks in advance. |
|
|||||
|
Usually in your pwd where you currently are. If done non-interactive via script and cronjob for example, you should do a cd to be sure, you are at the place in the filesystem, where you want to be.
I avoid to tar stuff with a leading slash. So I can always move to a tmp directory and extract there to avoid overwriting. It's always a bad surprise if some &*!@$! (to have it in comic speech censorship) creates an archive with absolute path. That can cause an unwanted update of your data heh. |
|
||||
|
Gnu tar helpfully removes any leading / in a path to avoid the potential problems that zaxxon describes -- unless specifically told to keep it with -P. If your tar doesn't do this, you can only do
Code:
tar -xf sam.tar /home/sam/E1.txt cp /home/sam/E1.txt /home/ram tar -x can only extract from the archive what you put in there; use -t (as zaxxon said) to see what that is. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|