saving . . . saved grep $ has been deleted. grep $ has been hidden .
grep $
Title
Question
We can find pattern at the end of the line by $. Can we find pattern at the beginning of the line? grep "[78]...$" grepdemo.txt, how this command find scholarship between 7000 to 8999 ? 

Linux More-on-grep-command 07-08 min 0-10 sec 05-12-20, 7:09 p.m. sanniddhachakrabarti@gmail.com

Answers:

Dear Sir,

Yes, you can use ^ to force a regex to match string only at the start of a line.

We can used $ to force a regex to match string only at the end of a line.

First we will take a look at only grep "[78]...", this searches string which start with 7 or 8 and followed by any three characters any where in the line.

grep "[78]...$"
In this regex because we have used $ symbol we are forcing grep to search only at the end of line.

--
Rohan
15-03-21, 1:56 p.m. rohmh


Log-in to answer to this question.