saving . . . saved grep "^A" grepdemo.txt has been deleted. grep "^A" grepdemo.txt has been hidden .
grep "^A" grepdemo.txt
Title
Question
grep "^A" grepdemo.txt, why this command only highlight the roll number starting with A, why not names ?

Linux More-on-grep-command 06-07 min 30-40 sec 05-12-20, 6:58 p.m. sanniddhachakrabarti@gmail.com

Answers:

Dear Sir,

You can use ^ to force a regex to match only at the start of a line.
As we have written grep "^A", this command will search "A" at the start of the each line in grepdemo.txt file and return roll number starting with A.
All names starting with "A" are present in between the line and not at the start of line. That's why regex doesn't highlight the name.

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


Log-in to answer to this question.