DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 2nd October 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default Negative Wildcard Matching

Hello,

In the shell, if you want to match a group of items based on a condition, you could use a wildcard. For example, if there was a bunch of .txt files in a directory, you could list only those items with % ls *.txt

Is there a way to match items based on the exclusion of a condition. Going with the .txt example, how would I select only those items in the directory that don't end in .txt?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #2   (View Single Post)  
Old 2nd October 2008
anomie's Avatar
anomie anomie is offline
Local
 
Join Date: Apr 2008
Location: Texas
Posts: 446
Thanked 69 Times in 46 Posts
Default

I'd pipe it to grep:
% ls | grep -v '\.txt\>'

If you are looking for a shell-globbing-only answer, I'm not sure.
__________________
Kill your t.v.

Last edited by anomie; 2nd October 2008 at 11:09 PM. Reason: escaped the dot.
Reply With Quote
  #3   (View Single Post)  
Old 3rd October 2008
BSDKaffee's Avatar
BSDKaffee BSDKaffee is offline
Real Name: Jason Hale
Coffee Addict
 
Join Date: May 2008
Location: Wintersville, Ohio
Posts: 212
Thanked 36 Times in 34 Posts
Default

You may want to use '$' for end of line, otherwise if you have a somefile.txt.bak it will get excluded by grep. E.g.:
$ ls | grep -v '\.txt$'
Reply With Quote
  #4   (View Single Post)  
Old 3rd October 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default

Thanks for the replies.

I have discovered that the caret symbol - ^ - is a shell glob that negates the normal meaning (works with tcsh at least).
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Negative partition size? giga FreeBSD General 1 2nd January 2009 09:02 PM


All times are GMT. The time now is 04:32 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick