The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
Use wildcards in a script emferrari Shell Programming and Scripting 13 03-07-2008 04:14 AM
Wildcards in SED HealthyGuy Shell Programming and Scripting 5 09-27-2006 08:32 PM
ls with wildcards benu302000 UNIX for Dummies Questions & Answers 10 06-29-2005 02:53 PM
wildcards benu302000 UNIX for Dummies Questions & Answers 3 06-29-2005 01:10 PM
Wildcards in VI peter.herlihy UNIX for Dummies Questions & Answers 8 01-08-2002 04:27 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-20-2007
C3000 C3000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
wildcards NOT

Hi All

Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines.

tar -cf archive.tar * <minus all *.rst files>

Can anyone help.

Thanks
Ed
  #2 (permalink)  
Old 11-20-2007
C3000 C3000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
I found the answer to my question here.

ITworld.com - UNIX SYSTEM ADMINISTRATION - Trimming Tar Files

Apologies I should have read the man page a little more closely before posting.

Ed
  #3 (permalink)  
Old 11-20-2007
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Helo, C3000.
There are several possibilities, depending on your tar version.
For instance, in my GNU tar 1.15.1, there are an option (have a look at tar man pages) like:
Quote:
[...]

--exclude=PATTERN
exclude files matching PATTERN

[...]
If this is not the case, you may do something like:
Code:
tar cvzf mytarfile.tgz $(find . ! -name '*rst')
Regards.
  #4 (permalink)  
Old 11-21-2007
C3000 C3000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Hello grial

I am running the HP-UX tar so unfortunately your first suggestion using -- exclude is not available to me and indeed my optimistic post above including the web link is not relevant in my case.

Your second option is more promising however I am attempting this opertion in the C shell and the command substitution $(find . ! -name '*rst') seems to be throwing a shell error. Is command substitution of this form possible in the csh and if not what are the options assuming I do not want to just fire up another shell.

Thanks

Ed
  #5 (permalink)  
Old 11-21-2007
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Well, I'm not used to csh, but I think this should work:
Code:
tar cvf mytarfile.tgz { find . ! -name '*rst' }
Regards.
  #6 (permalink)  
Old 11-21-2007
C3000 C3000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 19
Hi grial

Finally got this to work

tar cvf archive.tar `find . \! -name '*rst' -type f`

Back ticks seem to achieve the command substitution I am looking for in the c-shell and I had to modify your find command by adding the type f to prevent it from returning the directories including . This isn't ideal as I can see a scenario where I may want to find non-rst files in sub directories also.

Ed
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0