我无法理解为什么使用grep时,通配符 * 在以下示例中的解释方式不同:
find . -type f -name \*
结果:
./tgt/etc/test_file.c
./tgt/etc/speleo/test_file.c
./tgt/etc/other_file.c
./src/file.c
我希望您能从此命令中返回与模式匹配的文件,最好带有通配符*。但是:
find . -type f -name \* | grep "tgt/etc/*" # this one works
find . -type f -name \* | grep tgt/etc/* # not this one
find . -type f -name \* | grep tgt/et*/s* # this one works
find . -type f -name \* | grep "tgt/et*/s*" # not this one
我希望有一个实现可以适用于两种情况。我应该使用什么?
*
和文件名通配符中的作用是不同的,对吧? - Barmargrep file1 file2
将匹配到file1
和file2
两者。 - Reinstate Monica Please*
。 - Barmar