Syntax for tar command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Syntax for tar command
# 1  
Old 05-02-2001
I am trying to extract a file using tar. I cd'ed to the directory I wanted to start in. I had the tar file in the same directory. I executed tar xvf filename . It appeared that it was extracting into the directory the tar file was created from instead of into the directory I was in. How do I get tar to extract where I want? I looked at the man page and I have 2 books for help but I don't see what I did wrong.
thanks, john
# 2  
Old 05-02-2001
If the tarfile was created with directories in the archive, then those directories will be untarred when you do the untar boogie-woogie. Most people do this:

Code:
tar tvf filename | more

This allows them to examine the tarfile to see how it is structured before untarring. Then, they untar and move or rename directories as required. You can force tar to untar in another directory, but will still get the archived directories when you untar.

So, even if there is gold at the end of a filetree in the tarfile and you want only the gold, you have to untar the entire filesystem used in the creation to get to the gold!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX command to check if file name ends with .tar OR if the file is a tar file

Hello Team, Would you please help me with a UNIX command that would check if file is a tar file. if we dont have that , can you help me with UNIX command that would check if file ends with .tar Thanks in advance. (10 Replies)
Discussion started by: sanjaydubey2006
10 Replies

2. Shell Programming and Scripting

Single command - unzip files from a tar command

I have a tar file that contains multiple .Z files. Hence I need to issue a tar command followed by a gzip command to fully extract the files. How do I do it in a single command? What I'm doing now is tar xvf a.tar (this will output 1.Z and 2.Z) gzip -d *.Z (to extract 1.Z and 2.Z) (9 Replies)
Discussion started by: ericlim
9 Replies

3. UNIX for Dummies Questions & Answers

Dot and redirected output syntax in a tar command

Hi All, Please could anyone advise what the purpose of the dot syntax in the following command means: tar -cvf ${WORKING_BACKUP_ROOT}/${TAR_ARCHIVE_FILE} . >/${BACKUP_ROOT}/${ARCHIVE_LOG} Many thanks (2 Replies)
Discussion started by: daveu7
2 Replies

4. Shell Programming and Scripting

tar -C syntax question

I am writing a perl script to tar multiple files (in unix) from a given directory to a given output directory. I do NOT want the file path included in the tar, so I've flagged the -C option. Example: tar -cvf tar/1.tar -C htmp/source/ 1-1-1.xml However, I need to do this for a number of target... (3 Replies)
Discussion started by: michanjohns
3 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. Shell Programming and Scripting

Some help with tar options and syntax?

I've got a script that's first copying a list of files into /etc/confbackups after running some other stuff, I'm having trouble with tar now though. What I've got: tar -cCf $date.$list.tar.gz /etc/confbackups *.conf What I'm thinking this is supposed to do is create the archive as specified,... (4 Replies)
Discussion started by: Jandiedonkerman
4 Replies

7. HP-UX

ps command syntax

I use hp HP-UX. I want to get vsz of the process . What is the syntax ... /run>ps -help ps: illegal option -- h ps: option requires an argument -- p usage: ps (3 Replies)
Discussion started by: chuikingman
3 Replies

8. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

9. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

10. UNIX for Dummies Questions & Answers

command syntax

Hi, Does anyone knows the command syntax for the following Unix commands: at mount The OS is the Chorus/Mix 4.3 BSD Unix. The "at" command does the following: at a precise date and hour it executes a desirede command. Many thanks !!! Regards, Pedro Pereira (3 Replies)
Discussion started by: pmap
3 Replies
Login or Register to Ask a Question