Register
It is currently Sun Sep 21, 2014 12:03 am

listing wildcard with exemptions


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Sat May 15, 2010 6:20 pm   

Joined: Sat May 15, 2010 6:05 pm
Posts: 2
I am trying to get a list of files that do not include a group of characters withing a file name.
I can: ls *[!dod].so
and all files ending in dod.so are excluded
I can: ls [!dod]*.so and all *.so files that begin with dod are excluded.
I want to ls *[!dod]*.so to exclude all *.so that have dod anywhere in the file name to be excluded and ls grabs stuff even outside the dir I am in. Is this a bug or am I supposed to do something else to control the search. And if it is a bug is there a work around


Top
 Profile  
 PostPosted: Sat May 15, 2010 7:23 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 548
that's more a find job.


Top
 Profile  
 PostPosted: Sun May 16, 2010 6:41 am   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
LRC wrote:
I am trying to get a list of files that do not include a group of characters withing a file name.
I can: ls *[!dod].so
and all files ending in dod.so are excluded
I can: ls [!dod]*.so and all *.so files that begin with dod are excluded.
I want to ls *[!dod]*.so to exclude all *.so that have dod anywhere in the file name to be excluded and ls grabs stuff even outside the dir I am in. Is this a bug or am I supposed to do something else to control the search. And if it is a bug is there a work around

Your statements are not true. ls *[!dod].so is the same as ls *[^do].so: it matches everything except files with "d" or "o" before the .so extension.
You need to turn on the extglob option, then you can use:
Code:
ls !(*dod).so
ls !(dod*).so
ls !(*dod*).so


Top
 Profile  
 PostPosted: Sun May 16, 2010 1:02 pm   

Joined: Sat May 15, 2010 6:05 pm
Posts: 2
Many thanks. Works like a charm.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP