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 Users Found This Useful
Was this answer helpful?

Related Articles

Linux tar Command

The Linux tar command is used to compress and extract files to and from an archive. In this...

How to Install WordPress via SSH

Since WordPress is the most widely used CMS it’s installation process has been made as simple and...

SSH Execute Command on a Remote server

Via SSH you can connect to a remote server’s shell. This will allow you to execute commands on...

How to connect to your shared hosting account via SFTP with FileZilla

SFTP is a convenient way to use SSH, while also using the interface of a simple FTP. In order to...

SSH netstat command

If you wish to debug or track statistics of your network in a Linux environment you can use SSH...