SSH grep command

When you’re searching for a text in a particular file under a Linux system you’re usually using the grep command. grep stands for Get Regular Expression and Print, in this article we’ll show several examples of how to use the SSH grep command in your everyday server management and monitoring:

Using SSH grep command for a basic search

grep "textToSearchFor" file.txt

grep for a case-insensitive search

grep -i "THIS CASING DOESN'T MATTER" file.conf

grep without matching

grep -v "thisWillNotBeMatched" file.txt

grep for word matching

Usually, grep searches like how you would match a Regular Expression (as it’s in its name), if you would like to apply \b search you would use

grep -w "justThisWordWillBeMatched" file.cnf

grep for to count the number of occurrences

grep -c "howManyTimesThisAppearsInTheFile" file.php

SSH grep command with line numbers

This will show the number of the line the match is found

grep -n "whichLineIsThisOn" file.txt
  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

SSH ip command

If you wish to obtain information about your server’s IP on a Linux machine using SSH you can use...

SSH rm command

If you wish to remove a file or folder from your Linux system you can use SSH rm command. In this...

SSH echo command

One of the most useful commands in a Linux environment is echo. With it, you can provide output...

SSH history command

If you wish to find what commands you have previously executed in a Linux environment you can use...

SSH cd command

SSH cd command is mainly used to navigate in your Linux environment. In this article, we’ll show...

Powered by WHMCompleteSolution