Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple patterns with glob

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I know I can use glob to get a list of filenames like
[glob -nocomplain "$currentdir/*.log"]

How can I get a list with multiples patterns like *.log *.dat etc?

How can I get a list of files that are not in the patterns i.e not *.log*.exe?

Many thanks!
 
I don't think you can do the "not" match. According to the help file:
The pattern arguments may contain any of the following special characters:

? Matches any single character.

* Matches any sequence of zero or more characters.

[chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclusive) will match.

\x Matches the character x.

{a,b,...} Matches any of the strings a, b, etc.

As for the multiple patterns, just put them in the statement, separated by commas:
glob -nocomplain "$currentdir/*.log .dat ...

Bob Rashkin
rrashkin@csc.com
 
The results of glob are saved in a list so you can just
pass the urls to glob and save the results in named lists.
Code:
set loglist [glob $logdir/*.log]
set dblist [glob $dbdata/*.db]


HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top