您的位置:首页 > 运维架构 > Linux

【linux学习笔记】查找命令小结

2013-09-16 11:45 423 查看
1.find

使用形式:

<span style="font-size:14px"> find <指定目录> <指定条件> <指定动作></span>


实例:find / -name 'hiphop*'

/:根目录

-name : 按名字查询

‘hiphop*’ 名字开头是‘hiphop’的文件

2.whereis

whereis

whereis命令只能用于程序名的搜索,而且只搜索二进制文件(参数-b)、man说明文件(参数-m)和源代码文件(参数-s)。如果省略参数,则返回所有信息。

whereis命令的使用实例:

whereis grep

3.grep

grep [OPTIONS] PATTERN [FILE...]

grep -rE 'test*' /etc/passwd

查找当前目录下所有包含something的文件:

grep  -rE "*something*" ./


4.查找和替换

The :substitute command searches for a text
pattern, and replaces it with a text string. There are many options, but these are what you probably want:

:%s/foo/bar/g
Find each occurrence of 'foo' (in all lines), and replace it with 'bar'.

:s/foo/bar/g
Find each occurrence of 'foo' (in the current line only), and replace it with 'bar'.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: