tar - Selecting target dir


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers tar - Selecting target dir
# 1  
Old 11-03-2005
tar - Selecting target dir

Hi,
1 - How to select files to tar from a dir (indir) to the tar command?

2 - How to select the target directory where the files in a tar file should go to - I know that by default, tar remembers the path and restores files to that path.

I am using HP-UX

Thanks.
# 2  
Old 11-03-2005
I think that as a thumb rule, always use the relative path while creating archives with the tar command. Say you want to create a tar of all files with pattern *.txt from the /tmp directory, do it like this:
Code:
cd /tmp; tar -cf text.tar *.txt

This answers your first question. And also the second: since the path you have given to tar is a relative path (not starting with "/"), you can extract to a chosen directory like this:
Code:
cd /dir/to/extract; tar -xf text.tar

This will create the necessary directory structure under the directory where you have chosen to extract the files.
# 3  
Old 11-05-2005
Got it, thanks.
# 4  
Old 11-05-2005
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Assign read write permission to the user for specific dir and it's sub dir and files in AIX

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. I do not want to assign user the same group of that directories too.... (0 Replies)
Discussion started by: blinkingdan
0 Replies

2. UNIX for Dummies Questions & Answers

How do I create a tar file for only dir and its subdir structures??

How do I create a tar file for only dir and its subdir structures?? (4 Replies)
Discussion started by: vx04
4 Replies

3. HP-UX

After adding new iscsi target port, still the session state of that target port is showing offline

Hi, I wanted to configure new iscsi port on HPUX system, i added the target port address and configured it, once done, went to array side and searched for that host iqn number , but was nt able to find the same, came to host, then when i ran "iscsiutil -pVS" command it gave me below result ... (0 Replies)
Discussion started by: Vinay Kumar D
0 Replies

4. Shell Programming and Scripting

HELP! I want to locate only dir and tar.gz

I making a script to restore apache from a configuration_backup tar. For now i want at the beginning of the script that you can make a choice to choose one of the configuration_backup tars. I use this code now: `locate /restore/configuration/configuration_backup*` But if i use this i get... (1 Reply)
Discussion started by: dannyvdberg
1 Replies

5. Shell Programming and Scripting

How to tar this dir excluding some files .au?

Hi all, Thanks for previous help. How to include this in script, I need to tar files which are present in /var/spool/cron/crontabs directory (used for crontab) excluding those files which are having extension .au /var/spool/cron/crontabs>>ls -ltr | grep -v .au total 438 -rw------- 1... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

6. 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

7. 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

8. UNIX for Dummies Questions & Answers

Tar Exclude Dir with a Specific Words

So here is what I got i have these directories names app-config app-exploded conf gen logs match src target currently i do: tar -cvf file.tar conf gen logs match src target What i want to do is: tar -cvf file.tar (exclude any dir with "app" in it) How can i... (1 Reply)
Discussion started by: rhartleyoh
1 Replies

9. Shell Programming and Scripting

a script to clone a dir tree, & overwrite the dir struct elsewhere?

hi all, i'm looking for a bash or tcsh script that will clone an empty dir tree 'over' another tree ... specifically, i'd like to: (1) specify a src directory (2) list the directory tree/hiearchy beneath that src dir, w/o files -- just the dirs (3) clone that same, empty dir hierarchy to... (2 Replies)
Discussion started by: OpenMacNews
2 Replies

10. UNIX for Advanced & Expert Users

selective tar image and dir perms

Hi, I'm creating a tar image containing selected files held in a manifest file thus: cat <manifest file> | xargs tar -cvpf tar.out I need to preserve the directory as well as the file perms. When my list contains no separate directory lines, the directory is created implicitly when the... (4 Replies)
Discussion started by: gfarley
4 Replies
Login or Register to Ask a Question