- 论坛徽章:
- 0
|
用find命令查找当前目录下任何文件名的普通文件时,如果用以下命令:
find . -name * -type f
则会提示:
find: 路径必须在表达式之前: dir0
用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
如果把星号quote掉,就可以执行
find . -name \* -type f
或者
find . -name "*" -type f
或者
find . -name '*' -type f
执行结果都一样”:
./file.bak
./services.zip
./newdir.tar.gz
./file.both
./test1
./newdir/newfile5
./dir1/dir10/dir100.txt
./dir1/dir11/dir110.txt
./tmp.log
./test
问题1:
正确执行的命令,星号是被当作wildcard还是被当作RE中的一个modifier?
if(result(问题1)== wildcard) then
问题2:
星号(*)在command line里面是个meta,属于wildcard,代表匹配0个或多个字符,为什么不能用在-name后面的argument里面呢?
else if (result(问题1)== RE中的一个modifier)then
问题3:
如果quote掉,星号代表RE中的一个修饰字符(modifier),表示前一个字符集出现0次或者多次,上面正确执行的命令里面没有在星号前面给出任何字符集(char.set),这样的话星号只能代表一个普通字符啊。RE中的(.)点号表示任意单一字符,我用命令find . -name ".*" -type f 测试,结果是:
./.test.swp
./.test1.swp
这个又说明星号是重复他前面的字符集(char.set),点号在这里也仅仅代表一个普通字符而已。他们并不能被看作是RE。
else
救救我。
|
|