Chinaunix

标题: 如何搜索想要的字符串. [打印本页]

作者: bartzhangsh    时间: 2015-07-16 16:39
标题: 如何搜索想要的字符串.
我在一个文件中,想要查找一个特定的字符串在哪里,我怎么找呢.
就像ctrl+f这样的功能.我找到后要定位,然后可以看前面后面的内容.
谢谢!
作者: ningquec    时间: 2015-07-16 16:50
使用grep命令
作者: lyhabc    时间: 2015-07-16 23:18
用less 命令,然后 /要查找的东西
或者直接vi那个文件
作者: bartzhangsh    时间: 2015-07-17 10:38
回复 3# lyhabc

请问一下怎么用呢?
less +/erromsg runtime.log
这样么?

vi, vi怎么用用/erromsg这样么?

   
作者: misatt    时间: 2015-07-17 11:02
grep findname file
作者: bartzhangsh    时间: 2015-07-17 13:14
回复 5# misatt


    grep: 不能打开文件 logfile.log
作者: leijskg    时间: 2015-07-17 15:27
提示: 作者被禁止或删除 内容自动屏蔽
作者: lyhabc    时间: 2015-07-17 22:24
@bartzhangsh
对的
http://www.cnblogs.com/peida/archive/2012/11/05/2754477.html
作者: cu_shell    时间: 2015-07-19 11:26
grep “erromsg” /var/log/runtime.log  #假如路径是这样的话

或者

vi /var/log/runtime.log
然后直接输入 /
再输入erromsg回车
作者: bartzhangsh    时间: 2015-07-22 15:59
谢谢,结贴.





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2