简体   繁体   English

Glob 文件,除了包含一些表达式

[英]Glob files except that including some expression

I want to write a command to build FooMain.cc among the following files:我想编写一个命令来在以下文件中构建FooMain.cc

$ 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.每个主文件(包括Main的文件)都有main() function 并且它们需要文件名中没有Main的所有其他文件。

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 .这里的表达式HelperOne.cc FileToInclude.cc...包括除Main之外的所有文件。 What I want to do is rephrase this expression with glob expression我想做的是用 glob 表达式改写这个表达式

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 ):使用ksh93bash并打开extglob选项 ( shopt -s extglob ),或使用zsh并打开ksh_glob选项 ( setopt ksh_glob ):

$ clang++ [options] FooMain.cc !(*Main*).cc

Using zsh with the extended_glob option turned on ( setopt extended_glob ):在启用extended_glob选项的情况下使用zsh ( setopt extended_glob ):

$ clang++ [options] FooMain.cc *.cc~*Main*

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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