原帖由 nhw_cs 于 2009-12-17 22:37 发表
其实你这孩子挺可教的, 看注册时间应该是初学者, 此时就能刨根问题关注这样的问题,相信不久就能成为高手. 当你理解了UNIX很多现象背后的原理, 必然豁然开朗 .... 很多看似理所当然的事情, 背后都有更多的秘 ...
原帖由 nhw_cs 于 2009-12-17 22:43 发表
我看错了 ..你举的例子好像有问题.. 应该是 grep '[Ff]irst *’.txt 与 grep [Ff]irst *.txt 比较, 这是有区别的
原帖由 yazi0127 于 2009-12-18 13:17 发表
找了个环境试了一下:
cat aa.txt
first
second
First
Second
grep [Ff]irst *.txt
无返回
grep '[Ff]irst' *.txt
aa.txt:first
aa.txt:First
grep "[Ff]irst" *.txt
...
Pathname Expansion
After word splitting, unless the -f option has been set, bash scans
each word for the characters *, ?, and [. If one of these characters
appears, then the word is regarded as a pattern, and replaced with an
alphabetically sorted list of file names matching the pattern. If no
matching file names are found, and the shell option nullglob is dis-
abled, the word is left unchanged. If the nullglob option is set, and
no matches are found, the word is removed. If the failglob shell
option is set, and no matches are found, an error message is printed
and the command is not executed. If the shell option nocaseglob is
enabled, the match is performed without regard to the case of alpha-
betic characters. When a pattern is used for pathname expansion, the
character ‘‘.’’ at the start of a name or immediately following a
slash must be matched explicitly, unless the shell option dotglob is
set. When matching a pathname, the slash character must always be
matched explicitly. In other cases, the ‘‘.’’ character is not
treated specially.
原帖由 ywlscpl 于 2009-12-18 14:07 发表
[root@Mylinux tmp]# cat a.txt
a.txt first
a.txt First
[root@Mylinux tmp]# cat first
first
First
[root@Mylinux tmp]# grep '[fF]irst' *.txt
a.txt first
a.txt First
[root@Mylinux tmp]# grep ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |