---
title: "How can I find all files containing specific text (string) on Linux?"  
description: "How can I find all files containing specific text (string) on Linux?"  
author: "Utpal Vishwas"  
published: 2023-07-14  
updated: 2023-07-15  
canonical: https://www.mindstick.com/forum/159085/how-can-i-find-all-files-containing-specific-text-string-on-linux  
category: "linux"  
tags: ["file", "linux"]  
reading_time: 2 minutes  

---

# How can I find all files containing specific text (string) on Linux?

How can I find all [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud) containing specific [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) ([string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)) on [Linux](https://www.mindstick.com/blog/11489/linux-os)?

## Replies

### Reply by Aryan Kumar

Sure, there are a few ways to find all files containing specific text on Linux. Here are two methods:

**Method 1: Using the** `find` **command**

The `find` command is a command-line tool that can be used to find files and directories. To find all files containing specific text, you can use the following syntax:

```plaintext
find <path> -name "*.txt" -exec grep -i "<text>" {} \;
```

For example, to find all files containing the text "hello" in the current directory, you would run the following command:

```plaintext
find . -name "*.txt" -exec grep -i "hello" {} \;
```

The `-name` option tells the `find` command to only search for files that match the specified name pattern.

The `-exec` option tells the `find` command to execute the specified command for each file that is found.

The `grep` command is a command-line tool that can be used to search for text in files. The `-i` option tells the `grep` command to ignore case when searching for text.

**Method 2: Using the** `grep` **command**

The `grep` command is a command-line tool that can be used to search for text in files. To find all files containing specific text, you can use the following syntax:

```plaintext
grep -i "<text>" <directory_path>/*.txt
```

For example, to find all files containing the text "hello" in the current directory, you would run the following command:

```plaintext
grep -i "hello" ./*.txt
```

The `-i` option tells the `grep` command to ignore case when searching for text.

The `<directory_path>` parameter is the path to the directory that you want to search.

The `*.txt` pattern tells the `grep` command to only search for files that have the `.txt` extension.


---

Original Source: https://www.mindstick.com/forum/159085/how-can-i-find-all-files-containing-specific-text-string-on-linux

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
