Ubuntu: how to find a word or string of text in files

You are here:
  • Main
  • Ubuntu
  • Ubuntu: how to find a word or string of text in files
← All Topics

To search for a word a specific string of text from the command line in Ubuntu you can use the following method:

You can use grep in the terminal and if needed you can recursively search through directories using -r option

grep -r "text string to search" "directory name"

For example, to search for the string "idfa" in all files in all subdirectories of "/weapons/ammo/" the command looks like this:

grep -r "idfa" "/weapons/ammo/"

The quotation marks are not always needed, you will need the quotation marks if your text string or directory path contains blankspaces.