我无法弄清楚为什么在以下示例中使用grep对野生字符*进行不同的解释:
find . -type f -name \*
Run Code Online (Sandbox Code Playgroud)
结果:
./tgt/etc/test_file.c
./tgt/etc/speleo/test_file.c
./tgt/etc/other_file.c
./src/file.c
Run Code Online (Sandbox Code Playgroud)
我想从这个命令返回匹配模式的文件,最终是通配符*.但是:
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
Run Code Online (Sandbox Code Playgroud)
我希望有一个适用于两种情况的实现.我该怎么用?