小编Art*_*gma的帖子

Shell UNIX:grep外卡

我无法弄清楚为什么在以下示例中使用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)

我希望有一个适用于两种情况的实现.我该怎么用?

unix bash shell grep wildcard

3
推荐指数
1
解决办法
8666
查看次数

标签 统计

bash ×1

grep ×1

shell ×1

unix ×1

wildcard ×1