11.04中grep ^问题

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

11.04中grep ^问题

#1

帖子 yechf » 2011-09-12 14:58

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,却出不来结果。
有谁可以帮忙试试?
头像
sunfish
帖子: 989
注册时间: 2008-05-03 1:53

Re: 11.04中grep ^问题

#2

帖子 sunfish » 2011-09-12 15:10

测试过可以的,查看以下你的文件看the是不是在行首,有空格也不行的
docker && kubernetes
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

Re: 11.04中grep ^问题

#3

帖子 yechf » 2011-09-12 15:24

regular_express.txt
不是我的文件。
别人行,我不行,我就疑问了。
头像
sunfish
帖子: 989
注册时间: 2008-05-03 1:53

Re: 11.04中grep ^问题

#4

帖子 sunfish » 2011-09-12 15:27

我自己造了个文件测试的 :em06
docker && kubernetes
头像
yechf
帖子: 305
注册时间: 2006-04-27 12:18
来自: 浙江德清武康

Re: 11.04中grep ^问题

#5

帖子 yechf » 2011-09-12 15:40

是我的问题。

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

谢谢楼上。
回复