Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

learn unix and linux commands

tar'ing and regular expressions

UNIX for Dummies Questions & Answers


Tags
regex, regular expressions

 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-10-2007   -   Original Discussion by sirbrian
sirbrian's Unix or Linux Image
sirbrian sirbrian is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 14 July 2009, 10:04 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
tar'ing and regular expressions

Hi,

How do I tar all but a specific set of files in a directory? Is it possible to use regular expressions in the tar command? I want to tar all files except those beginning with D. I tried this

tar -cvf files.tar ^[^D]

but this didn't work. Anyone any ideas.

Thanks
Sponsored Links
    #2  
Old Unix and Linux 07-10-2007   -   Original Discussion by sirbrian
radoulov's Unix or Linux Image
radoulov radoulov is offline
Registered User
 
Join Date: Jan 2007
Last Activity: 9 January 2017, 4:40 AM EST
Location: Варна, България / Milano, Italia
Posts: 5,690
Thanks: 184
Thanked 630 Times in 587 Posts


Code:
tar cvf files.tar [!D]*

In some cases you have to escape the bang ([\!D]).
Sponsored Links
    #3  
Old Unix and Linux 07-10-2007   -   Original Discussion by sirbrian
sirbrian's Unix or Linux Image
sirbrian sirbrian is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 14 July 2009, 10:04 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Radoulov. That's cracked it.
Sponsored Links
 


Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regular expressions help linuxkid Shell Programming and Scripting 6 07-30-2010 04:49 AM
sed and regular expressions AlbertGM Shell Programming and Scripting 6 10-13-2009 09:32 AM
SED regular expressions noppeli Shell Programming and Scripting 3 09-10-2009 08:53 AM
Need help with Regular Expressions jidsh Shell Programming and Scripting 5 04-20-2009 05:00 PM
Regular Expressions ramky79 UNIX for Advanced & Expert Users 3 05-21-2008 06:13 PM



All times are GMT -4. The time now is 01:32 PM.