What is the command to find the differences in the lines containing - ProProfs Discuss
Advertisement

What is the command to find the differences in the lines containing "2011" between the files a1.txt and a2.txt?

What is the command to find the differences in the lines containing "2011" between the files a1.txt and a2.txt?<br/>

Change Image    Delete

Asked by Nbans, Last updated: Dec 15, 2024

+ Answer
Request
Question menu
Vote up Vote down

3 Answers

othersidee

othersidee

othersidee
Othersidee

Answered Jun 08, 2018

Diff a1.txt a2.txt | grep 2011

upvote downvote
Reply 

h.Jennifer

h.Jennifer

h.Jennifer
H.Jennifer

Answered Apr 23, 2018

Diff a1.txt a2.txt | grep 2011.
The name, “grep”, derives from the command used to perform a similar operation, using the Unix/Linux text editor ed:g/re/p.

When you search for boo, grep will match fooboo, boo123, barfoo35 and more. You can force the grep command to select only those lines containing matches that form whole words i.e. match only boo word.
Use the egrep command as follows:
$ egrep -w 'word1|word2' /path/to/file

The grep can report the number of times that the pattern has been matched for each file using -c (count) option:
$ grep -c 'word' /path/to/file

Pass the -n option to precede each line of output with the number of the line in the text file from which it was obtained:
$ grep -n 'root' /etc/passwd

upvote downvote
Reply 

John Smith

John Smith

John Smith
John Smith

Answered Dec 12, 2016

Diff a1.txt a2.txt | grep 2011
upvote downvote
Reply 

Advertisement
Advertisement
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader
Image Preview
Search for Google images Google Image Icon
Select a recommended image
Upload from your computer Loader

Email Sent
We have sent an email to your address "" with instructions to reset your password.