Grep words with special symbols

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
1












How do I grep this? (Including the special characters)



"Limit reached."[n]"


I tried back-slashing the special symbols but end up not working, like this:



grep '"Limit reached."[\n]" '


I also tried other techniques but also not working. Is there any other syntax you could suggest/advice?










share|improve this question









New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    is space after last double quote a typos ?
    – Archemar
    yesterday










  • No, but I also tried with no space
    – Cyril
    yesterday










  • Double quotes are not paired. Is it normal?
    – Fólkvangr
    yesterday















up vote
5
down vote

favorite
1












How do I grep this? (Including the special characters)



"Limit reached."[n]"


I tried back-slashing the special symbols but end up not working, like this:



grep '"Limit reached."[\n]" '


I also tried other techniques but also not working. Is there any other syntax you could suggest/advice?










share|improve this question









New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    is space after last double quote a typos ?
    – Archemar
    yesterday










  • No, but I also tried with no space
    – Cyril
    yesterday










  • Double quotes are not paired. Is it normal?
    – Fólkvangr
    yesterday













up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





How do I grep this? (Including the special characters)



"Limit reached."[n]"


I tried back-slashing the special symbols but end up not working, like this:



grep '"Limit reached."[\n]" '


I also tried other techniques but also not working. Is there any other syntax you could suggest/advice?










share|improve this question









New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











How do I grep this? (Including the special characters)



"Limit reached."[n]"


I tried back-slashing the special symbols but end up not working, like this:



grep '"Limit reached."[\n]" '


I also tried other techniques but also not working. Is there any other syntax you could suggest/advice?







linux grep special-characters






share|improve this question









New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

36.3k1271116




36.3k1271116






New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Cyril

282




282




New contributor




Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Cyril is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    is space after last double quote a typos ?
    – Archemar
    yesterday










  • No, but I also tried with no space
    – Cyril
    yesterday










  • Double quotes are not paired. Is it normal?
    – Fólkvangr
    yesterday













  • 1




    is space after last double quote a typos ?
    – Archemar
    yesterday










  • No, but I also tried with no space
    – Cyril
    yesterday










  • Double quotes are not paired. Is it normal?
    – Fólkvangr
    yesterday








1




1




is space after last double quote a typos ?
– Archemar
yesterday




is space after last double quote a typos ?
– Archemar
yesterday












No, but I also tried with no space
– Cyril
yesterday




No, but I also tried with no space
– Cyril
yesterday












Double quotes are not paired. Is it normal?
– Fólkvangr
yesterday





Double quotes are not paired. Is it normal?
– Fólkvangr
yesterday











2 Answers
2






active

oldest

votes

















up vote
11
down vote



accepted










use -F in grep



$ cat test.txt
"Limit reached."[n]"
test
"Limit reached."[n]"

$ grep -F '"Limit reached."[n]"' test.txt
"Limit reached."[n]"
"Limit reached."[n]"


As per Manual page,




 -F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX,
--fixed-regexp is an obsoleted alias, please do not use it new scripts.)






share|improve this answer




















  • This is good and simple. Thanks!
    – Cyril
    yesterday










  • There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
    – Marc van Leeuwen
    yesterday










  • @MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
    – terdon♦
    yesterday

















up vote
5
down vote













You were very close.



You do not need to excape ", and cannot use shell-escape in single quotes. Therefore all escaping is for grep, not for the shell. (Note on single quotes: single quotes does no interpretation. If you need to put a single quote withing a single quoted string, then you have to come out of single quotes e.g. 'don'''t' )



Test



printf "%s" '"Limit reached."[n]"' | grep '"Limit reached."[\n]"'





share|improve this answer




















  • Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
    – Cyril
    yesterday










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Cyril is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468192%2fgrep-words-with-special-symbols%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
11
down vote



accepted










use -F in grep



$ cat test.txt
"Limit reached."[n]"
test
"Limit reached."[n]"

$ grep -F '"Limit reached."[n]"' test.txt
"Limit reached."[n]"
"Limit reached."[n]"


As per Manual page,




 -F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX,
--fixed-regexp is an obsoleted alias, please do not use it new scripts.)






share|improve this answer




















  • This is good and simple. Thanks!
    – Cyril
    yesterday










  • There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
    – Marc van Leeuwen
    yesterday










  • @MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
    – terdon♦
    yesterday














up vote
11
down vote



accepted










use -F in grep



$ cat test.txt
"Limit reached."[n]"
test
"Limit reached."[n]"

$ grep -F '"Limit reached."[n]"' test.txt
"Limit reached."[n]"
"Limit reached."[n]"


As per Manual page,




 -F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX,
--fixed-regexp is an obsoleted alias, please do not use it new scripts.)






share|improve this answer




















  • This is good and simple. Thanks!
    – Cyril
    yesterday










  • There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
    – Marc van Leeuwen
    yesterday










  • @MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
    – terdon♦
    yesterday












up vote
11
down vote



accepted







up vote
11
down vote



accepted






use -F in grep



$ cat test.txt
"Limit reached."[n]"
test
"Limit reached."[n]"

$ grep -F '"Limit reached."[n]"' test.txt
"Limit reached."[n]"
"Limit reached."[n]"


As per Manual page,




 -F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX,
--fixed-regexp is an obsoleted alias, please do not use it new scripts.)






share|improve this answer












use -F in grep



$ cat test.txt
"Limit reached."[n]"
test
"Limit reached."[n]"

$ grep -F '"Limit reached."[n]"' test.txt
"Limit reached."[n]"
"Limit reached."[n]"


As per Manual page,




 -F, --fixed-strings, --fixed-regexp
Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by> POSIX,
--fixed-regexp is an obsoleted alias, please do not use it new scripts.)







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Kamaraj

2,8551413




2,8551413











  • This is good and simple. Thanks!
    – Cyril
    yesterday










  • There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
    – Marc van Leeuwen
    yesterday










  • @MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
    – terdon♦
    yesterday
















  • This is good and simple. Thanks!
    – Cyril
    yesterday










  • There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
    – Marc van Leeuwen
    yesterday










  • @MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
    – terdon♦
    yesterday















This is good and simple. Thanks!
– Cyril
yesterday




This is good and simple. Thanks!
– Cyril
yesterday












There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
– Marc van Leeuwen
yesterday




There is also the fgrep command, which as per the manpage does just grep -F. Personally I always use fgrep unless I know I am really using a regexp.
– Marc van Leeuwen
yesterday












@MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
– terdon♦
yesterday




@MarcvanLeeuwen it might be a good idea to get used to grep -F since fgrep and egrep are only included for backwards compatibility now that POSIX specifies -F and -E.
– terdon♦
yesterday












up vote
5
down vote













You were very close.



You do not need to excape ", and cannot use shell-escape in single quotes. Therefore all escaping is for grep, not for the shell. (Note on single quotes: single quotes does no interpretation. If you need to put a single quote withing a single quoted string, then you have to come out of single quotes e.g. 'don'''t' )



Test



printf "%s" '"Limit reached."[n]"' | grep '"Limit reached."[\n]"'





share|improve this answer




















  • Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
    – Cyril
    yesterday














up vote
5
down vote













You were very close.



You do not need to excape ", and cannot use shell-escape in single quotes. Therefore all escaping is for grep, not for the shell. (Note on single quotes: single quotes does no interpretation. If you need to put a single quote withing a single quoted string, then you have to come out of single quotes e.g. 'don'''t' )



Test



printf "%s" '"Limit reached."[n]"' | grep '"Limit reached."[\n]"'





share|improve this answer




















  • Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
    – Cyril
    yesterday












up vote
5
down vote










up vote
5
down vote









You were very close.



You do not need to excape ", and cannot use shell-escape in single quotes. Therefore all escaping is for grep, not for the shell. (Note on single quotes: single quotes does no interpretation. If you need to put a single quote withing a single quoted string, then you have to come out of single quotes e.g. 'don'''t' )



Test



printf "%s" '"Limit reached."[n]"' | grep '"Limit reached."[\n]"'





share|improve this answer












You were very close.



You do not need to excape ", and cannot use shell-escape in single quotes. Therefore all escaping is for grep, not for the shell. (Note on single quotes: single quotes does no interpretation. If you need to put a single quote withing a single quoted string, then you have to come out of single quotes e.g. 'don'''t' )



Test



printf "%s" '"Limit reached."[n]"' | grep '"Limit reached."[\n]"'






share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









ctrl-alt-delor

9,11431948




9,11431948











  • Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
    – Cyril
    yesterday
















  • Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
    – Cyril
    yesterday















Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
– Cyril
yesterday




Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
– Cyril
yesterday










Cyril is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Cyril is a new contributor. Be nice, and check out our Code of Conduct.












Cyril is a new contributor. Be nice, and check out our Code of Conduct.











Cyril is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468192%2fgrep-words-with-special-symbols%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery