分页: 1 / 1

11.04中grep ^问题

发表于 : 2011-09-12 14:58
yechf
http://linux-vbird.bluedata.org/linux_b ... ularex.htm



例题三、行首与行尾字符 ^ $:
我们在例题一当中,可以查询到一行字符串里面有 the 的,那如果我想要让 the 只在行首列出呢? 这个时候就得要使用定位字符了!我们可以这样做:[root@test root]# grep -n '^the' regular_express.txt
12:the symbol '*' is represented as start.


可是我用grep -n '^the' regular_express.txt,却出不来结果。
有谁可以帮忙试试?

Re: 11.04中grep ^问题

发表于 : 2011-09-12 15:10
sunfish
测试过可以的,查看以下你的文件看the是不是在行首,有空格也不行的

Re: 11.04中grep ^问题

发表于 : 2011-09-12 15:24
yechf
regular_express.txt
不是我的文件。
别人行,我不行,我就疑问了。

Re: 11.04中grep ^问题

发表于 : 2011-09-12 15:27
sunfish
我自己造了个文件测试的 :em06

Re: 11.04中grep ^问题

发表于 : 2011-09-12 15:40
yechf
是我的问题。

那文件无法下载。我是选中后中键粘帖的。
结果前面真的有空格了。

谢谢楼上。