Emacs – 用emacs的文件夹中搜索文件

本文介绍了Emacs中几种实用的文件搜索命令,包括find-name-dired(按名称搜索)、find-grep-dired(按内容搜索)及find-dired(自定义条件搜索),帮助用户灵活高效地查找文件。

Emacs – 用emacs的文件夹中搜索文件

作者:fangzhzh
声明:允许未经作者的同意进行非商业目的的转载,但必须保证原文完整性

find-name-dired 在文件夹中搜索文件(按名字,递归)
find-grep-dired 同上(搜索文件中的内容,递归)
find-dired 同上(自由度最高,所有选项自己设置,需要熟悉find)


Dired and find

You can select a set of files for display in a Dired buffer more
flexibly by using the find utility to choose the files.


find-name-dired

To search for files with names matching a wildcard pattern use M-x
find-name-dired. It reads arguments directory and pattern, and chooses
all the files in directory or its subdirectories whose individual names
match pattern.

The files thus chosen are displayed in a Dired buffer in which the
ordinary Dired commands are available.


find-grep-dired

If you want to test the contents of files, rather than their names, use
M-x find-grep-dired. This command reads two minibuffer arguments,
directory and regexp; it chooses all the files in directory or its
subdirectories that contain a match for regexp. It works by running the
programs find and grep. See also M-x grep-find, in Compilation.
Remember to write the regular expression for grep, not for Emacs. (An
alternative method of showing files whose contents match a given regexp
is the % g regexp command, see Marks vs Flags.)


find-dired

The most general command in this series is M-x find-dired, which lets
you specify any condition that find can test. It takes two minibuffer
arguments, directory and find-args; it runs find in directory, passing
find-args to tell find what condition to test. To use this command, you
need to know how to use find.


others

M-x locate provides a similar interface to the locate program. M-x
locate-with-filter is similar, but keeps only lines matching a given
regular expression.

The format of listing produced by these commands is controlled by the
variable find-ls-option, whose default value specifies using options
-ld for ls. If your listings are corrupted, you may need to change the
value of this variable.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值