![how to search for text in files in current directory linux how to search for text in files in current directory linux](https://scdn1.plesk.com/wp-content/uploads/2021/04/19122842/Plesk360_750x250_V2.png)
That’s it! With this command, you will be able to search for text in hundreds or thousands of files, just replace the /path string with path you want to search the text in, and the text string with the text you want to find.įor a quick example, let’s say I want to find the word “Menu” in a directory called “9to5linux” containing 305 items (including files and folders) in my Home directory. So, to search for text within thousands of files contained in a hierarchy of folders, you only need a single line of command that you can run on a terminal emulator. It’s main purpose is to search patterns in each file, but it supports complex rules.
![how to search for text in files in current directory linux how to search for text in files in current directory linux](https://www.computerhope.com/cdn/linux/find.gif)
The grep (global regular expression print) command is very powerful and probably the most versatile of Linux commands. What do you do? Of course, looking into every single files would be mission impossible, so here’s Linux’s grep command to the rescue. You need to quickly find a single word or several within these files. It doesn’t matter the extension of the files contained in these folders as they can be whatever crosses your mind, e.g.txt. If you are a developer, a web programmer, or someone who works with many files and you need to find a single piece of text, you should know and memorize a single command you can use on any Linux-based system.įor example, let’s say you have a directory containing 30 folders and 20,000 files.
HOW TO SEARCH FOR TEXT IN FILES IN CURRENT DIRECTORY LINUX HOW TO
The following tutorial will show you how to search for specific text within many files and folders in a GNU/Linux distribution using a single line of command.