如何搜索.module文件的内容?

时间:2021-01-10 15:03:01

I'm working with Drupal at the moment and I'm having a real hard time searching the contents of various .module files. For example I want to search for something like "div style="border: 1px solid red;" and find out which file it's in.

我目前正在与Drupal合作,我很难搜索各种.module文件的内容。例如,我想搜索类似“div style =”border:1px solid red;“并找出它所在的文件。

All my code editors ignore the .module files in their search because it is a strange extension. Windows won't do it because it's on a networked location.

我的所有代码编辑都忽略了搜索中的.module文件,因为它是一个奇怪的扩展。 Windows不会这样做,因为它位于网络位置。

Any ideas?

3 个解决方案

#1


Install Cygwin, open a shell in your Drupal site's directory, and use grep --- a commandline utility to search files using regular expressions.

安装Cygwin,在Drupal站点的目录中打开一个shell,并使用grep ---命令行实用程序使用正则表达式搜索文件。

Something like this:

像这样的东西:

grep -r 'div style="border: 1px solid red;"' *

would recursively search every file for that string.

将以递归方式搜索该字符串的每个文件。

Or:

find . -name '*.module' -exec grep -H 'div style="border: 1px solid red;"' {} \;

would search only the .module files.

只搜索.module文件。

#2


ack can do that for you pretty happily. For more convenience, you can also add in your .ackrc file the following: --type-set=drupal=.php,.inc,.module,.install,.info,.engine --type=drupal

ack可以非常愉快地为你做到这一点。为了更方便,您还可以在.ackrc文件中添加以下内容: - type-set = drupal = .php,.inc,.module,.install,。info,.engine - type = drupal

So that typing

这样输入

$ ack string

will find string in all drupal files under the current directory.

将在当前目录下的所有drupal文件中找到字符串。

(Yes, it runs on windows, see the link).

(是的,它在Windows上运行,请参阅链接)。

#3


What I do:

我所做的:

Use firebug, it will tell you the exact file and then you can browse the system for that style. You'll want to turn off CSS caching for this temporarily.

使用firebug,它会告诉您确切的文件,然后您可以浏览系统中的该样式。您将暂时关闭此CSS缓存。

Generally, there aren't too many (or shouldn't be any) CSS rules being defined in the .module files anyway.

通常,.module文件中定义的CSS规则并不太多(或不应该是)。

If all else fails, you can use something like Agent Ransack or, for a more command line unixy feel, the king of command line search: grep.

如果所有其他方法都失败了,你可以使用像Agent Ransack这样的东西,或者为了更多的命令行unixy感觉,命令行搜索之王:grep。

#1


Install Cygwin, open a shell in your Drupal site's directory, and use grep --- a commandline utility to search files using regular expressions.

安装Cygwin,在Drupal站点的目录中打开一个shell,并使用grep ---命令行实用程序使用正则表达式搜索文件。

Something like this:

像这样的东西:

grep -r 'div style="border: 1px solid red;"' *

would recursively search every file for that string.

将以递归方式搜索该字符串的每个文件。

Or:

find . -name '*.module' -exec grep -H 'div style="border: 1px solid red;"' {} \;

would search only the .module files.

只搜索.module文件。

#2


ack can do that for you pretty happily. For more convenience, you can also add in your .ackrc file the following: --type-set=drupal=.php,.inc,.module,.install,.info,.engine --type=drupal

ack可以非常愉快地为你做到这一点。为了更方便,您还可以在.ackrc文件中添加以下内容: - type-set = drupal = .php,.inc,.module,.install,。info,.engine - type = drupal

So that typing

这样输入

$ ack string

will find string in all drupal files under the current directory.

将在当前目录下的所有drupal文件中找到字符串。

(Yes, it runs on windows, see the link).

(是的,它在Windows上运行,请参阅链接)。

#3


What I do:

我所做的:

Use firebug, it will tell you the exact file and then you can browse the system for that style. You'll want to turn off CSS caching for this temporarily.

使用firebug,它会告诉您确切的文件,然后您可以浏览系统中的该样式。您将暂时关闭此CSS缓存。

Generally, there aren't too many (or shouldn't be any) CSS rules being defined in the .module files anyway.

通常,.module文件中定义的CSS规则并不太多(或不应该是)。

If all else fails, you can use something like Agent Ransack or, for a more command line unixy feel, the king of command line search: grep.

如果所有其他方法都失败了,你可以使用像Agent Ransack这样的东西,或者为了更多的命令行unixy感觉,命令行搜索之王:grep。