tar the entire directory except one directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tar the entire directory except one directory
# 1  
Old 09-02-2009
tar the entire directory except one directory

Hi All,

I need to tar the entire directory except one directory inside that.
I have used the below command

tar -cvfX test.tar bin/perl bin/

I need to tar all the directories inside the bindirectory except the perl directory

Please help me in solving this Smilie

Regards,
Kalai
# 2  
Old 09-02-2009
Quote:
Originally Posted by kalpeer
...
I need to tar all the directories inside the bindirectory except the perl directory
...
If you are using the GNU version of tar utility, then you may use the "--exclude" option of this command.

tyler_durden
# 3  
Old 09-02-2009
tar -cvfX test.tar bin/ --exclude bin/perl
its not working.
Please provide me the syntax of it
# 4  
Old 09-02-2009
Let me guess, you're getting an error like
Code:
tar: test.tar: Cannot stat: No such file or directory

and there's suddenly a file named 'X' in the current directory?

You've mixed up the order of the option switches. '-f' takes the next argument to be the name of the file where it should tar into, in your case 'X'. If you want to use the -X switch, you should provide a file with the patters you want to exclude. So the correct syntax should probably be:
Code:
tar -cvf test.tar --exclude bin/perl bin/

# 5  
Old 09-02-2009
Bug

Thanks for your information.
tar -cvf test.tar --exclude bin/perl bin/
When i execute i am getting the below error
tar: --exclude: No such file or directory

---------- Post updated at 01:22 AM ---------- Previous update was at 12:34 AM ----------

I got a solution.
Put the excluded file or directory name in some temporary file (/tmp/test)

then execute tar -cvfX test.tar /tmptest *

Thanks All Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find and get a file in an entire directory with an excluded directory specified?

How to get a file 'zlib.h' in an entire directory with an excluded directory specified lives under that starting directory by using find command, as it failed on: $ find . -name 'zlib.h' -a -ipath 'CHROME.TMP' -prune -o -print it'll just list entirely up (2 Replies)
Discussion started by: abdulbadii
2 Replies

2. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

3. UNIX for Dummies Questions & Answers

Append two lines of text to php.ini in the entire directory tree.e

I am looking to write a script that will read the php.ini files on my web host. If the two lines do exist do nothing. If not append two lines to the end of it then move on to the next directory and open the next php.ini file. I have the beginning of one that was given to me on another web site but... (6 Replies)
Discussion started by: Larrykh465
6 Replies

4. Shell Programming and Scripting

Looping through entire directory and count unique values

Hello, I`m a complete newbie to coding, please help with this problem. I have multiple files in a directory, I have to loop through the contents of each file and extract number of unique isoforms in that file. Each file is tab delimited and only the line with the first parent (column 3)... (1 Reply)
Discussion started by: ritakadm
1 Replies

5. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

6. AIX

Using restorevgfiles to restore entire directory from rootvg problems

I am trying to restore a specific directory and all sub-directories therein using a rootvg tape. I am using the following command to make the backup: mksysb -m -i -v /dev/rmt0 However, I am getting the following result: tctl status rmt0 Available 04-08-00-0,0 LVD SCSI 4mm Tape Drive... (10 Replies)
Discussion started by: herot
10 Replies

7. UNIX for Advanced & Expert Users

How to rsync or tar directory trees, with hidden directory, but without files?

I want to backup all the directory tress, including hidden directories, without copying any files. find . -type d gives the perfect list. When I tried tar, it won't work for me because it tars all the files. find . -type d | xargs tar -cvf a.tar So i tried rsync. On my own test box, the... (4 Replies)
Discussion started by: fld2007
4 Replies

8. UNIX for Dummies Questions & Answers

tar directory -C

I m new to unix and trying to use tar command with -C option - tar -cf /tmp/Test_shell/ZipTestFolder/archive10.tar -C /tmp/Test_shell/ZipTestFolder/ . It creates one more folder no_name inside the tar file. any suggestions how to remove it. I m using aix 5.3 (8 Replies)
Discussion started by: abhishek1.618
8 Replies

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

10. UNIX for Dummies Questions & Answers

how to zip the entire directory

my first question is how to zip the entire directory contents. second question is can we unzip the same file through windows environment. please help i need to complete it by EOD (3 Replies)
Discussion started by: bbc17484
3 Replies
Login or Register to Ask a Question