> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# HOW TO : Find files, search for content in them, replace the content
- URL: https://kudithipudi.org/how-to-find-files-search-for-content-in-them-replace-the-content/
- Published: 2012-08-16T14:07:32.000Z
- Updated: 2012-08-16T14:07:32.000Z
- Description: The title pretty much says it all :). Here is a quick one liner, using multiple tools, to look for files in a directory, search for...
- Author: admin
- Tags: Linux, Technology, Uncategorized, commandfu, howto, linux, perl, #wp, #wp-post, #Import 2026-08-23 02:32

The title pretty much says it all :). Here is a quick one liner, using multiple tools, to look for files in a directory, search for certain content in them and replace them with other content

```
find -type f | xargs grep -l ORIGINAL_CONTENT | xargs perl -p -i -e ‘s/ORIGINAL_CONTENT/NEW_CONTENT/g’
```

You can theoretically take out the grep (second command) and directly pipe the find output to perl and get the same outcome.

Going over list of the options used

**find**

- “-type f” lists all objects of type file in the directory (and sub directories)

**grep**

- “-l” lists the names of the files (with relative path) which have the text ORIGINAL\_CONTENT in them

**perl**

- “-p” forces perl to loop through requests. In this case files
- “-e” tells perl that the next argument is a perl statement
- “-i” tells perls to edit the file in place (i.e. no need for an output file)