The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 09-24-2008
osramos osramos is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 21
Oh, i see.

Another problem i have, assuming i'm using " ls !(pattern) ", is the shell i'm using.

The server is a Windows Server but have installed CYGWIN and Bash doesn't recognize the " ! ".

Is there other solution?

Regards,

osramos

Quote:
Originally Posted by jim mcnamara View Post
What you are asking is to create a resultset that all files minus pattern1 minus pattern2

The only problem for this is that we will have to use grep -v. The file matching patterns become regular expressions

Code:
??????.xls
# becomes regex:
[0-9]{6}\.xls

This will happen for every file you want to exclude. Otherwise, you cannot just
Code:
ls !(pattern)

for five different files because each instance of !(pattern2) will show other patterns like pattern2 pattern3... etc.

Code:
# generalized solution
ls directory | grep -v -e 'regex1' -e 'regex2' -e 'regex3'

Therefore you have to construct 50 different regexes (one for each file you have to specify) and apply some of them to the correct directory output from ls. I cannot do that for you.