Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux : Search for a Particular word in a List of files under a directory

Tags:

linux

I have a big list of log files in a particular directory , related to my java Application under my Linux Remote Servers .

When i do ls on that particular directory it shows a list of files (nearly 100 files )

Now in that List of files , i need to find out a particular word , please tell me , how can i do this ??

The problem is that I cannot open each and every file and search for that word using /

Please tell me how can i search for a word in the list of files provided .

like image 578
Pawan Avatar asked Mar 12 '12 10:03

Pawan


People also ask

How do I search for a specific word in multiple files in Linux?

To search multiple files with the grep command, insert the filenames you want to search, separated with a space character. The terminal prints the name of every file that contains the matching lines, and the actual lines that include the required string of characters. You can append as many filenames as needed.

How do I find a specific word in a directory in Linux?

A simple way to work this out is by using grep pattern searching tool, is a powerful, efficient, reliable and most popular command-line utility for finding patterns and words from files or directories on Unix-like systems.

How do I search for files containing a specific word?

Search for specific text with grep command Without a doubt, grep is the best command to search a file (or files) for a specific text. By default, it returns all the lines of a file that contain a certain string.


1 Answers

You can use this command:

grep -rn "string" * 

n for showing line number with the filename r for recursive

like image 69
Ashkan Avatar answered Sep 21 '22 19:09

Ashkan