• Arun Kumar

Shell Script to Find Text Tiles Containing Word 'user_defind'

Linux shell script allows user to find the word containing in files in a directory. In order to achieve this, we are using the find and grep command. Here the user will be asked to enter the text to search.

vi search_in_files.sh
# !/bin/bash
echo "Type the word to find text files"
read fn
find . -exec grep -l "$fn" {} \;

Here is the sample output of the above script

More ways to use find and grep

  • You can select only those lines containing matches that form whole words using the -w option.

  • You can also use this to search for two or more words - egrep -w -R 'word1|word2' ~/projects/


Recent Posts

See All

Basic Linux Commands

This article describes basic Linux commands that you must know as a system or database administrator. Below commands in Linux help you manage any Linux server fast and smoothly. Linux Command List Che

Linux Firewall with iptables and firewalld

In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside ipt

Passwordless SSH in Linux

Every time you ssh from one Linux server to another, you need to enter target server user's password. We can also setup passwordless ssh in Linux between two Linux servers so that you don't have to en