Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
Using the grep Command in Linux: Finding Text & Strings in Files
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
In this guide, you’ll learn how to use the grep
command. When performing administrative tasks on your Linode, many commands will give you more information than you need. Using grep
allows you to filter that output in order to find only the data that’s relevant.
To search a file for a particular string, provide the string and filename as arguments:
grep 'some text' /etc/ssh/sshd_config
You may also redirect output from a command to
grep
using a pipe:tail -f /var/log/apache/error.log | grep 'some text'
This will monitor your Apache error logs, and display only the lines of output that contain the given string.
Regex patterns are also supported by the
-E
option if you want to search for a set of strings rather than one literal:grep -E "[[:alpha:]]{16,20}" /etc/ssh/sshd_config
This example will search the
/etc/ssh/sshd_config
file for strings of alphabetic characters that are 16-20 characters long, but you can use any regex pattern you like.
These are simply a few basic ways to use grep
. Many other options exist, and in combination with other tools, it serves as an invaluable utility for performing administrative tasks on your Linode. For more information on some of grep
’s advanced features, check out our guide on how to
search and filter text with grep.
This page was originally published on