Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
45
rated 0 times [  45] [ 0]  / answers: 1 / hits: 1872  / 2 Years ago, fri, april 1, 2022, 1:04:25

What is the difference between grep apple file and grep "apple" file? What does putting the quotation marks do? They both appear to work and do the exact same thing (display same line).


More From » bash

 Answers
1

The quotation marks have an effect on what characters your shell considers special and to have a syntactic meaning. In your example this doesn't make a difference because apple contains no such characters.



But consider another example: grep apple tree file will search for the word apple in the files tree and file, whereas grep "apple tree" file will search the word apple tree in the file file. The quotation marks tell bash, that the word space in "apple tree" does not start a new parameter but shall be part of the current parameter. grep apple tree file would produce the same result, because tells bash to disregard the special meaning of the following character and treat it literally.


[#29185] Saturday, April 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
farnic

Total Points: 409
Total Questions: 117
Total Answers: 125

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;