
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to Recursively Search all Files for Strings on a Linux
The grep command is used to search text or scans the given record for lines containing a match to the given strings or words. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. Using the grep command, we can recursively search all files for a string on a Linux.
Syntax of is shown as below-
$ grep -r "word"
For example, for searching “Linux” word in Downloads directory. The command should be like this
~/Downloads$ grep -r "Linux"
The sample output should be like this –
zookeeper_installation.htm:<li><p><b>Any of Linux OS</b> − Supports development and deployment. It is preferred for demo applications.</p></li> Linux Howtos.html:1. How to add a New Disk Drive to a Linux System? Linux Howtos.html:http://www.yolinux.com/TUTORIALS/LinuxTutorialAdditionalHardDrive.html Linux Howtos.html:2. How to create a new virtual disk for an existing Linux virtual machine? Linux Howtos.html:4. How to Increase the size of a Linux LVM by adding a new disk Linux Howtos.html:5. How to format a Linux Hard Disk? Linux Howtos.html:6. How to partition and format a new drive in Linux System? Linux Howtos.html:7. How to mount NTFS Drives on a Linux System?
To ignore case distinctions, use the following command –
$ grep -ri "linux" .
The sample output should be like this –
zookeeper_installation.htm:<li><p><b>Any of Linux OS</b> − Supports development and deployment. It is preferred for demo applications.</p></li> zookeeper_installation.htm:<p>The latest version (while writing this tutorial) is JDK 8u 60 and the file is “jdk-8u60-linuxx64.tar.gz”. Please download the file on your machine.</p> zookeeper_installation.htm:$ tar -zxf jdk-8u60-linux-x64.gz
To display print only filenames with GNU grep, use the following command –
$grep -r -l "linux"
You can also specify directory name, by using the following command –
$ grep -r -l "linux" /path/to/dir/*.c
Congratulations! Now, you know “How to Recursively Search all files for a string on a Linux”. We’ll learn more about these types of commands in our next Linux post. Keep reading!
- Related Articles
- How to Search and Remove Directories Recursively on Linux?
- How to search contents of multiple pdf files on Linux?
- How to use chmod recursively on Linux?
- How to touch all the files recursively using Python?
- How to find all files with names containing a string on Linux?
- Move all files except one on Linux
- Java program to delete all the files in a directory recursively (only files)
- Java program to List all files in a directory recursively
- Recursively List All Files in a Directory Including Symlinks
- How to unzip all zipped files in a Linux directory?
- How to rename multiple files recursively using Python?
- Diff a Directory for Only Files of a Specific Type on Linux
- Recursive Search and Replace in Text Files in Linux
- Find all links for a specific file on Linux
- List files recursively in C#
