'Glob files except that including some expression
I want to write a command to build FooMain.cc among the following files:
$ ls src
FooMain.cc
FooMain2.cc
BarMain.cc
Helper.cc
Helper.h
FileToInclude.cc
FileToInclude.h
...
Each main file (those including Main) has main() function and they require all the other files without Main in filenames.
The straightforward way to build would be like:
clang++ [options] FooMain.cc Helper.cc FileToInclude.cc ...
Here the expression HelperOne.cc FileToInclude.cc ... includes all the files but those including Main.
What I want to do is rephrase this expression with glob expression
clang++ [options] FooMain.cc [Some clever glob expression]
I looked up for a while but could not find similar questions. Appreciate any clues. Thank you!
Solution 1:[1]
Using ksh93, bash with the extglob option turned on (shopt -s extglob), or zsh with the ksh_glob option turned on (setopt ksh_glob):
$ clang++ [options] FooMain.cc !(*Main*).cc
Using zsh with the extended_glob option turned on (setopt extended_glob):
$ clang++ [options] FooMain.cc *.cc~*Main*
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shawn |
