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
New contributor
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
New contributor
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
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
New contributor
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
New contributor
New contributor
edited yesterday
Rui F Ribeiro
36.3k1271116
36.3k1271116
New contributor
asked yesterday
Cyril
282
282
New contributor
New contributor
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
add a comment |Â
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
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
yesterday
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
yesterday
@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â¦
yesterday
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
yesterday
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
yesterday
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
yesterday
@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â¦
yesterday
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
yesterday
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
yesterday
@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â¦
yesterday
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 yesterday
Kamaraj
2,8551413
2,8551413
This is good and simple. Thanks!
â Cyril
yesterday
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
yesterday
@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â¦
yesterday
add a comment |Â
This is good and simple. Thanks!
â Cyril
yesterday
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
yesterday
@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â¦
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
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
yesterday
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
yesterday
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 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
add a comment |Â
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
add a comment |Â
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.
Cyril is a new contributor. Be nice, and check out our Code of Conduct.
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
yesterday
No, but I also tried with no space
â Cyril
yesterday
Double quotes are not paired. Is it normal?
â Fólkvangr
yesterday