Grep words with special symbols
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
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
add a comment |Â
up vote
5
down vote
favorite
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
1
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
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
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
linux grep special-characters
edited Sep 11 at 7:49
Rui F Ribeiro
36.8k1273117
36.8k1273117
asked Sep 11 at 7:37
Cyril
332
332
1
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18
add a comment |Â
1
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18
1
1
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18
add a comment |Â
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.)
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
There is also thefgrep
command, which as per the manpage does justgrep -F
. Personally I always usefgrep
unless I know I am really using a regexp.
â Marc van Leeuwen
Sep 11 at 9:47
@MarcvanLeeuwen it might be a good idea to get used togrep -F
sincefgrep
andegrep
are only included for backwards compatibility now that POSIX specifies-F
and-E
.
â terdonâ¦
Sep 11 at 12:44
add a comment |Â
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]"'
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
add a comment |Â
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.)
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
There is also thefgrep
command, which as per the manpage does justgrep -F
. Personally I always usefgrep
unless I know I am really using a regexp.
â Marc van Leeuwen
Sep 11 at 9:47
@MarcvanLeeuwen it might be a good idea to get used togrep -F
sincefgrep
andegrep
are only included for backwards compatibility now that POSIX specifies-F
and-E
.
â terdonâ¦
Sep 11 at 12:44
add a comment |Â
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.)
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
There is also thefgrep
command, which as per the manpage does justgrep -F
. Personally I always usefgrep
unless I know I am really using a regexp.
â Marc van Leeuwen
Sep 11 at 9:47
@MarcvanLeeuwen it might be a good idea to get used togrep -F
sincefgrep
andegrep
are only included for backwards compatibility now that POSIX specifies-F
and-E
.
â terdonâ¦
Sep 11 at 12:44
add a comment |Â
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.)
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.)
answered Sep 11 at 7:55
Kamaraj
2,9081413
2,9081413
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
There is also thefgrep
command, which as per the manpage does justgrep -F
. Personally I always usefgrep
unless I know I am really using a regexp.
â Marc van Leeuwen
Sep 11 at 9:47
@MarcvanLeeuwen it might be a good idea to get used togrep -F
sincefgrep
andegrep
are only included for backwards compatibility now that POSIX specifies-F
and-E
.
â terdonâ¦
Sep 11 at 12:44
add a comment |Â
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
There is also thefgrep
command, which as per the manpage does justgrep -F
. Personally I always usefgrep
unless I know I am really using a regexp.
â Marc van Leeuwen
Sep 11 at 9:47
@MarcvanLeeuwen it might be a good idea to get used togrep -F
sincefgrep
andegrep
are only included for backwards compatibility now that POSIX specifies-F
and-E
.
â terdonâ¦
Sep 11 at 12:44
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
This is good and simple. Thanks!
â Cyril
Sep 11 at 8:06
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
Sep 11 at 9:47
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
Sep 11 at 9:47
@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â¦
Sep 11 at 12:44
@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â¦
Sep 11 at 12:44
add a comment |Â
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]"'
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
add a comment |Â
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]"'
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
add a comment |Â
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]"'
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]"'
answered Sep 11 at 7:55
ctrl-alt-delor
9,20431948
9,20431948
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
add a comment |Â
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
Thank you for this. This works also but on the real logs file, doesn't work. Good explanation though.
â Cyril
Sep 11 at 8:05
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
is space after last double quote a typos ?
â Archemar
Sep 11 at 7:43
No, but I also tried with no space
â Cyril
Sep 11 at 7:47
Double quotes are not paired. Is it normal?
â Fólkvangr
Sep 11 at 8:18