avatar Deluxe Blog Tips About Projects

Find all files containing a text

In the previous version of Meta Box, I removed the esc_meta function from the main class. And I need to find all files in all extensions to see if there's any subclass uses that function or if there's any reference to it.

The easiest way to do that is opening the wp-content/plugins folder in an editor like Visual Studio Code and press Cmd/Ctrl+Shift+F to search for a specific text across all files (esc_meta in my case). And you'll see a list of files containing that text. Clicking on each file shows you where the text is in the file.

Alternatively, if you prefer doing that with CLI, then use this command:

grep -rwl "esc_meta" /path/to/dir

Using grep is convenient if you don't have an editor to open a folder, such as when you're login to your server via SSH.

grep also has some options such as:

--include: search string in files matching the file name criteria. For example, search only files with *.php extension:

grep -rwl --include="*.php" "esc_meta" /path/to/dir

--exclude: exclude some files matching file name criteria. For example, don't search JavaScript files:

grep -rwl --exclude="*.js" "esc_meta" /path/to/dir

--exclude-dir: exclude some directories. For example, don't search for a text in any files in the tests folder:

grep -rwl --exclude-dir="tests" "esc_meta" /path/to/dir

🔥 HOT: Interested in boosting your WordPress SEO? My Slim SEO plugin is a super lighweight and automated plugin that handles most the hard work for you: meta tags, sitemap, redirection, schema & link building.

👉 Have a look and you will love it: wpslimseo.com

Comments