Command to locate the word within a text file


#1

Transfered from Linux Config Disqus comments:

Question:
Give the exact command that can locate the word “to” (without quotes) in a file named “file1” (without quotes), but does not display words like “total” or “stone” that are in the same file.
Answer:
-w option of a grep command allows user to search a content of a file for a words, where word is separated on both sides by a white space.


grep -w to file1 

#2