我在找带有特定扩展名的文件。例如,我想找到所有名为Robert的.pdf和.jpg文件
我知道我可以做这个命令
$ find . -name '*.h' -o -name '*.cpp'但是,除了扩展名之外,我还需要指定文件本身的名称。我只想看看是否有可能避免一遍又一遍地写文件名,谢谢!
发布于 2014-09-05 21:12:12
作为脚本,您可以使用:
find "${2:-.}" -iregex ".*${1:-Robert}\.\(h\|cpp\)$" -printfindcc并把它当作
findcc [name] [[search_direcory]]例如:
findcc # default name 'Robert' and directory .
findcc Joe # default directory '.'
findcc Joe /somewhere # no defaults注:您不能使用
findcc /some/where #eg without the name...另外,作为替代,您可以使用
find "$1" -print | grep "$@" 和
findcc directory grep_options喜欢
findcc . -P '/Robert\.(h|cpp)$'https://stackoverflow.com/questions/25693638
复制相似问题