Linux find text in files - with these commands it works
Linux is a free, UNIX-like operating system. Depending on the derivative, you have more or less of a user interface at your disposal. Regardless, you can perform various functions via the console. This includes, for example, finding files that contain a certain text.
How to find a text in files on your Linux system
Once you have installed Linux on your PC, navigation and operation is mostly done via the console. For this, you have numerous commands at your disposal, which you can use to perform any task with ease. For example, if you are looking for documents that contain a specific text, then this operation is also possible with a suitable command.- With the command "grep" you can search for a specific text within all files and output the file path.
- An example for this command is "grep -rnwi '/path/to/folder/' -e 'text'" without quotes at the beginning and end.
- The letters after "grep" specify how the search should be done. In this case, recursively (-r), the text must match completely (-w) and it should not be case sensitive (-i).
- Möchten Sie Beispielsweise im Ordner „Computer“ nach dem Text „Bild“ suchen, dann geben Sie als Befehl „grep -rwi '/home/Computer/' -e 'Bild'“ ohne Anführungszeichen an.
- Den Befehl können Sie durch verschiedene Zusätze Ihren gewünschten Suchanfragen anpassen.