论坛风格切换切换到宽版
  • 424阅读
  • 8回复

关于grep 的问题 [复制链接]

上一主题 下一主题
离线douxp.
 
发帖
2188
C币
-193049
威望
401
贡献值
1
银元
0
铜钱
4922
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-04-27
The data fi.le for the review questio.ns looks like this:.

Strawberry Jam.,300,191[成人用品]
Raspberry Jam,1.216,194              乙肝
Blueberry Jam,96.,195学习
Strawber.ry Compote,49,621学习
Raspberry Compo.te,19.37,624--------------彩票
Blueberry compote,200,6.25.
Fr.ozen Strawberries,130,194.1.
S.traw Hats,16,2047    美容

The f.irst field is the product name, the second field .is the quan.tity on hand,(广告)
and th.e third field is the product code. The fie.lds are separated by c.ommas.学习

In each of the following questions, write .a command using "grep" a.nd a           鲜花
regular expression. The da.ta fil.e in all cases is named "inventory".教育


Question 2

Display a list .of all of the lines in t.he file that. contain the word "Straw"(        游戏          )
right. before a space..


我的回答是: grep  "Straw" inventor..y.

为什么不对呢?

评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线huandream1.
发帖
1997
C币
-559569
威望
361
贡献值
5
银元
-1
铜钱
4513
人人网人气币
0
只看该作者 沙发  发表于: 2010-04-10
Re:关于grep
grep "Straw "  inventory
复制代码

离线laa110.
发帖
2019
C币
-152388
威望
394
贡献值
1
银元
-2
铜钱
4669
人人网人气币
0
只看该作者 板凳  发表于: 2010-04-10
Re:关于grep
哈哈,你没有注意那个right before a space, 就是Straw后面要有个空格。

发帖
2258
C币
-198163
威望
433
贡献值
1
银元
-2
铜钱
5064
人人网人气币
0
只看该作者 地板  发表于: 2010-04-10
Re:关于grep


QUOTE:哈哈,你没有注意那个right before a space, 就是Straw后面要有个空格。
neves_cu 发表于 2010-03-23 09:20



    谢谢,真的是

离线ing1024.
发帖
1895
C币
-236276
威望
326
贡献值
1
银元
-3
铜钱
4186
人人网人气币
0
只看该作者 4楼 发表于: 2010-04-10
Re:关于grep
那么Display all of the lines in the file that contain "Straw" at the START of the line。

应该用 grep 的哪一个选项呢?

发帖
1976
C币
-132244
威望
352
贡献值
1
银元
-3
铜钱
4443
人人网人气币
0
只看该作者 5楼 发表于: 2010-04-10
Re:关于grep
等会我面试通过了咱们再谈待遇

发帖
2004
C币
-236067
威望
351
贡献值
1
银元
-6
铜钱
4446
人人网人气币
0
只看该作者 6楼 发表于: 2010-04-10
Re:关于grep
你真厉害,比我强

离线donghai.
发帖
2040
C币
-60952
威望
331
贡献值
1
银元
-2
铜钱
4394
人人网人气币
0
只看该作者 7楼 发表于: 2010-04-10
Re:关于grep
最后一个问题了
Display all of the lines in the file where the last field is 4 digits long。
Search for "," before the field to make sure your regular expression matches
the whole field, use character classes to match four digits, and anchor it
to the end of the line to make sure it's the last field.

离线tonyfuming.
发帖
2210
C币
-234851
威望
424
贡献值
1
银元
-2
铜钱
4990
人人网人气币
0
只看该作者 8楼 发表于: 2010-04-10
Re:关于grep
本帖最后由 Moerae 于 2010-03-23 11:11 编辑

貌似是这样? 题目好长,没理解透彻

grep '[^0-9][0-9]\{4\}$'   inventory
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个