Linux: Find text in files

Linux: Find text in files


Referreport

Table of contents
  1. 1.Linux: Find text in files
  2. 2.Examples to search text in files (Linux)

Linux: Find text in files

  • -r means recursive.
  • -n shows the line of the file where the text snippet was found.
  • -w means that the text snippet as a whole must match. If you search for “house” with -w, you won’t find “front door”.
  • -i means that no distinction is made between upper and lower case.
  • -l can optionally be added to output only the file path in which the text snippet appears.
The command searches the home directory and subfolders of the user “zina” for files that contain the text “lorem”. (Image source: GIGA)

The command searches the home directory and subfolders of the user “zina” for files that contain the text “lorem”. (© GIGA)

Examples to search text in files (Linux)

  • Copying files and directories in Linux
  • The PING command in Linux explained
  • The LS command in Linux explained

Source: German