Linux Search text in files: grep
Search the console for the contents of specific files.
Search all files
The following command searches the contents of all files including files in subfolders:
grep -r SEARCHSTRING *
Search specific files
The following command searches the contents of all files with extension .php incl. files in the subfolders
find . -name *.php -exec grep -l SEARCHSTRING {} \;
Search specific files in specific folders
The following command searches the contents of all files with extension .php in folders that contain test in their name
find . -path *test* -name *.php -exec grep -l SEARCHSTRING {} \;
{{percentage}} % positive
THANK YOU for your review!
Top articles in this section
After I installed a fan in my NAS, it always ran at top speed. In the BIOS I could set the speed, but the automatic mode did not work properly. Using the service fancontrol the speed of the fan can be linked to any sensor and any threshold and controlled automatically.
To find out which folder needs how much space, the command “du” can be used on Debian. For an even better overview there is the commandline tool ncdu, which can analyze all folders similar to TreeSize.
The currently available Linux kernel has the version: 6.8.2 (found: 2024-03-27). Source: www.kernel.org. The Linux distributions, as an example Debian or Ubuntu used new kernel versions only with some delay, accordingly the used kernel versions are usually somewhat older. Which kernel is active on a Linux system can be read out with the following command: