简体   繁体   中英

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!

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*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM