Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
CentOS Quick Start Guide

You're reading from   CentOS Quick Start Guide Get up and running with CentOS server administration

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher
ISBN-13 9781789344875
Length 320 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Shiwang Kalkhanda Shiwang Kalkhanda
Author Profile Icon Shiwang Kalkhanda
Shiwang Kalkhanda
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with CentOS 7 FREE CHAPTER 2. Command-Line and Filesystem Navigation 3. Managing Text Files 4. User and Group Management 5. Managing File Permissions 6. Process Management 7. Managing Networking in CentOS 8. Software Package Management 9. Overview of Essential Advance Utilities 10. Other Books You May Enjoy

Using grep for text matching

Grep (short for Global Regular Expression Print) is a command that is used extensively to as a text search tool in text files. It searches for a pattern in a file and prints the corresponding line, which contains the matching pattern. It scans files for specified patterns and can be used with regular expressions, as well as text strings. Its syntax is as follows:

$ grep [options] pattern [files]

The following table demonstrates when the grep command is used:

Command

Usage

grep 'student' /etc/passwd

Search for a string, student, in a file, /etc/passwd, and print all matching lines

grep -v 'student' /etc/passwd

Print all lines that do not contain the string student

grep -i 'STUDENT' /etc/passwd

Search for a string, STUDENT, in a case-insensitive manner and print all matching lines (-i ignore case...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime