Exclude Directories in my tar command


 
Thread Tools Search this Thread
Operating Systems AIX Exclude Directories in my tar command
# 1  
Old 10-16-2013
Wrench Exclude Directories in my tar command

Hi, im having some issues after i execute the next command:

Code:
tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz

this creates the desired "test.tar.gz" file, but whe i try to open it it says "tar: 0511-164 There is a media read or write block size error."

My main goal is to tar the directory "jfma" and exclude the subdirectory DWEXPORTS as specified in my excludefile, and then zip it.

This is what my excludefile has:

DWEXPORTS:
# 2  
Old 10-16-2013
The tape archive will be in the file given to the f option. You need to gzip that one, not stdout which will contain a log of tar's actions but no meaningful data. By adding the z option, tar will gzip its output immediately.

And, remove the ":" from your exclude file.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 10-16-2013
z flag not recognized

Quote:
Originally Posted by RudiC
The tape archive will be in the file given to the f option. You need to gzip that one, not stdout which will contain a log of tar's actions but no meaningful data. By adding the z option, tar will gzip its output immediately.

And, remove the ":" from your exclude file.
Hi, thank you for your quick reply... Thing is im on AIX 6.1 and it doesnt accept the "z" flag. I already removed the ":" from my exclude file though.
# 4  
Old 10-16-2013
Specify a filename of - with -f so that you can pipe the archive itself to gzip.

Regards,
Alister
# 5  
Old 10-16-2013
Wrench

Quote:
Originally Posted by alister
Specify a filename of - with -f so that you can pipe the archive itself to gzip.

Regards,
Alister
Sorry Alister, and correct me if im wrong (and i believe i am) but isn't it already -f in my statement?
Code:
tar "-cvf"

....

Code:
tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz

If i am wrong how should i establish my statement. Im confused.

thanks again for your time.
# 6  
Old 10-16-2013
tar -cvf - -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz
This User Gave Thanks to CarloM For This Post:
# 7  
Old 10-16-2013
Quote:
Originally Posted by alister
Specify a filename of - with -f so that you can pipe the archive itself to gzip.

Regards,
Alister
Quote:
Originally Posted by CarloM
tar -cvf - -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz
CarloM, thank you i was actually working with:

Code:
tar -cvf /varios/restore/test.tar -X excludefile.txt /jfma/test1/

and after that i was going to execute the gzip. Two sentences to be clear, but yours worked for me.

Thank you. God Bless.SmilieSmilieSmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Tar Ball command to exclude directories

Hi, uname -a SunOS mymac 5.11 11.2 sun4u sparc SUNW,SPARC-Enterprise I need to tar a folder /tmp/moht but do not want these three folders to be included in the tar file -> savejpg, bmpsave and imgsave I tried --exclude, -path, -not options but it says bad option Can you help me with... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies

3. Shell Programming and Scripting

working with tar exclude command

i have issue with tar, let me explain when i run below command it works perfectly as usual. tar -cvf /tmp/temp.tar --exclude="exclusion expression" dir my requirement is --exclude="exclusion expression" will come from another variable. so when i execute below command: tar -cvf... (2 Replies)
Discussion started by: ajayyadavmca
2 Replies

4. UNIX for Dummies Questions & Answers

Executing a tar command with the --exclude option in a Debian shell script.

Hi All, I am trying to execute the following tar command with two --exclude options to suppress extract of the two directories specified. Do I need to single quote the directory paths ?? Many thanks for your help. The relevant code excerpt from the script is: cd /var/www/${SITE} ... (7 Replies)
Discussion started by: daveu7
7 Replies

5. UNIX for Dummies Questions & Answers

Find command to exclude directories and setup alias or script?

Hi, Firstly - sorry for the duplicate my other post looked like i was posting a how to for people. But i am wanting some help :P I want to search from / to find files and exclude my mounted ntfs drives. I have found this thread (Which I can't post the URL to until i have 5 posts) it's... (4 Replies)
Discussion started by: mightymouse2045
4 Replies

6. Shell Programming and Scripting

Perl exclude directories in command line

Hi, I use find command to list all the files in a directory and its sub-directories, but the problem is to exclude certain directories during search. Can i give the directory names in command line to skip them and search rest of the directories? For example i have directories: test ../test1... (1 Reply)
Discussion started by: nmattam
1 Replies

7. Shell Programming and Scripting

Help - Find command to exclude sub-directories

Hi Forum. I'm trying to write a script that finds and deletes files that are older than 300 days. The script will read a table that contains the following 3 columns: 1st col: Y means sub-directory scan; "N" means no subdirectory scan 2nd col: sub-directory location 3rd col: File prefix... (7 Replies)
Discussion started by: pchang
7 Replies

8. UNIX for Dummies Questions & Answers

How to Exclude multiple directories from find command?

Hi, Can some one help me how to exclude multiple directories using find command.. I have the directory structure below. /a/a1/b1 /a/c1/c2 /a/d1/d2/d3 I want to exlcude a1,c2and d3 from the above using find,can some one suggest pls.. thanks in advance... Use code tags... (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

9. UNIX for Dummies Questions & Answers

find command to exclude directories

Howdy I have this directory structure ... eep eepaptest eepfatest eepgltest eep.old eeppoptest ehf ehfaptest ehfgltest ehp ehpgltest I want to find files in these directories, but I want to exclude eep, ehf & ehp. Cany anyone help with the correct command ?? (1 Reply)
Discussion started by: SmurfGGM
1 Replies
Login or Register to Ask a Question