(Possible) inconsistent behavior of grep and less
Clash Royale CLAN TAG#URR8PPP
I have a utf-8 file containing some Turkish text inside. (My system is MacOSX)
$ file -I foo.merge
$foo.merge: text/plain; charset=utf-8
When I try to see some Turkish specific characters by using grep
, there is no problem:
$ grep 'Emiroğlu' foo.merge
EMİROĞLU Emiroğlu+Noun+A3sg+Pnon+Nom Emiroğlu+Noun+Prop+Noun+A3sg+P3sg+Nom Emiroğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
I can also see the file by using less
command without any problem.
However if I try to do the following, the Turkish characters are not seen properly:
$ grep 'Emir' foo.merge | less
EMİROĞLU ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+A3sg+Pnon+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+P3sg+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
Or the following also doesn't work:
$grep 'Emir' foo.merge > foo2.out
$less foo2.out
What could be the problem? Here is some additional information:
$ locale
LANG="en_US.utf-8"
LC_COLLATE="en_US.utf-8"
LC_CTYPE="en_US.utf-8"
LC_MESSAGES="en_US.utf-8"
LC_MONETARY="en_US.utf-8"
LC_NUMERIC="en_US.utf-8"
LC_TIME="en_US.utf-8"
LC_ALL="en_US.utf-8"
files grep unicode character-encoding less
add a comment |
I have a utf-8 file containing some Turkish text inside. (My system is MacOSX)
$ file -I foo.merge
$foo.merge: text/plain; charset=utf-8
When I try to see some Turkish specific characters by using grep
, there is no problem:
$ grep 'Emiroğlu' foo.merge
EMİROĞLU Emiroğlu+Noun+A3sg+Pnon+Nom Emiroğlu+Noun+Prop+Noun+A3sg+P3sg+Nom Emiroğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
I can also see the file by using less
command without any problem.
However if I try to do the following, the Turkish characters are not seen properly:
$ grep 'Emir' foo.merge | less
EMİROĞLU ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+A3sg+Pnon+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+P3sg+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
Or the following also doesn't work:
$grep 'Emir' foo.merge > foo2.out
$less foo2.out
What could be the problem? Here is some additional information:
$ locale
LANG="en_US.utf-8"
LC_COLLATE="en_US.utf-8"
LC_CTYPE="en_US.utf-8"
LC_MESSAGES="en_US.utf-8"
LC_MONETARY="en_US.utf-8"
LC_NUMERIC="en_US.utf-8"
LC_TIME="en_US.utf-8"
LC_ALL="en_US.utf-8"
files grep unicode character-encoding less
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
@zwlayer Oh, I sawEMİROĞLU
and thought that was the expected output.
– Kusalananda
Feb 3 at 10:46
@Kusalananda Yup,EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he getsESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead ofEmiroğlu
– zwlayer
Feb 3 at 10:50
1
Yourgrep
is using terminal control sequences to highlight (color) the matched string, whichless
does not understand by default. Look for agrep
option to turn off coloring (in GNU--color=never
or--color=auto
) or useless -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.
– dave_thompson_085
Feb 3 at 11:19
add a comment |
I have a utf-8 file containing some Turkish text inside. (My system is MacOSX)
$ file -I foo.merge
$foo.merge: text/plain; charset=utf-8
When I try to see some Turkish specific characters by using grep
, there is no problem:
$ grep 'Emiroğlu' foo.merge
EMİROĞLU Emiroğlu+Noun+A3sg+Pnon+Nom Emiroğlu+Noun+Prop+Noun+A3sg+P3sg+Nom Emiroğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
I can also see the file by using less
command without any problem.
However if I try to do the following, the Turkish characters are not seen properly:
$ grep 'Emir' foo.merge | less
EMİROĞLU ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+A3sg+Pnon+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+P3sg+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
Or the following also doesn't work:
$grep 'Emir' foo.merge > foo2.out
$less foo2.out
What could be the problem? Here is some additional information:
$ locale
LANG="en_US.utf-8"
LC_COLLATE="en_US.utf-8"
LC_CTYPE="en_US.utf-8"
LC_MESSAGES="en_US.utf-8"
LC_MONETARY="en_US.utf-8"
LC_NUMERIC="en_US.utf-8"
LC_TIME="en_US.utf-8"
LC_ALL="en_US.utf-8"
files grep unicode character-encoding less
I have a utf-8 file containing some Turkish text inside. (My system is MacOSX)
$ file -I foo.merge
$foo.merge: text/plain; charset=utf-8
When I try to see some Turkish specific characters by using grep
, there is no problem:
$ grep 'Emiroğlu' foo.merge
EMİROĞLU Emiroğlu+Noun+A3sg+Pnon+Nom Emiroğlu+Noun+Prop+Noun+A3sg+P3sg+Nom Emiroğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
I can also see the file by using less
command without any problem.
However if I try to do the following, the Turkish characters are not seen properly:
$ grep 'Emir' foo.merge | less
EMİROĞLU ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+A3sg+Pnon+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+P3sg+Nom ESC[1;35;40mESC[KEmirESC[mESC[Koğlu+Noun+Prop+Noun+A3sg+Pnon+Nom NOTFOUND
Or the following also doesn't work:
$grep 'Emir' foo.merge > foo2.out
$less foo2.out
What could be the problem? Here is some additional information:
$ locale
LANG="en_US.utf-8"
LC_COLLATE="en_US.utf-8"
LC_CTYPE="en_US.utf-8"
LC_MESSAGES="en_US.utf-8"
LC_MONETARY="en_US.utf-8"
LC_NUMERIC="en_US.utf-8"
LC_TIME="en_US.utf-8"
LC_ALL="en_US.utf-8"
files grep unicode character-encoding less
files grep unicode character-encoding less
edited Feb 3 at 13:27
Jeff Schaller
42.1k1156133
42.1k1156133
asked Feb 3 at 10:34
user334928user334928
61
61
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
@zwlayer Oh, I sawEMİROĞLU
and thought that was the expected output.
– Kusalananda
Feb 3 at 10:46
@Kusalananda Yup,EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he getsESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead ofEmiroğlu
– zwlayer
Feb 3 at 10:50
1
Yourgrep
is using terminal control sequences to highlight (color) the matched string, whichless
does not understand by default. Look for agrep
option to turn off coloring (in GNU--color=never
or--color=auto
) or useless -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.
– dave_thompson_085
Feb 3 at 11:19
add a comment |
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
@zwlayer Oh, I sawEMİROĞLU
and thought that was the expected output.
– Kusalananda
Feb 3 at 10:46
@Kusalananda Yup,EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he getsESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead ofEmiroğlu
– zwlayer
Feb 3 at 10:50
1
Yourgrep
is using terminal control sequences to highlight (color) the matched string, whichless
does not understand by default. Look for agrep
option to turn off coloring (in GNU--color=never
or--color=auto
) or useless -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.
– dave_thompson_085
Feb 3 at 11:19
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
@zwlayer Oh, I saw
EMİROĞLU
and thought that was the expected output.– Kusalananda
Feb 3 at 10:46
@zwlayer Oh, I saw
EMİROĞLU
and thought that was the expected output.– Kusalananda
Feb 3 at 10:46
@Kusalananda Yup,
EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he gets ESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead of Emiroğlu
– zwlayer
Feb 3 at 10:50
@Kusalananda Yup,
EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he gets ESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead of Emiroğlu
– zwlayer
Feb 3 at 10:50
1
1
Your
grep
is using terminal control sequences to highlight (color) the matched string, which less
does not understand by default. Look for a grep
option to turn off coloring (in GNU --color=never
or --color=auto
) or use less -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.– dave_thompson_085
Feb 3 at 11:19
Your
grep
is using terminal control sequences to highlight (color) the matched string, which less
does not understand by default. Look for a grep
option to turn off coloring (in GNU --color=never
or --color=auto
) or use less -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.– dave_thompson_085
Feb 3 at 11:19
add a comment |
1 Answer
1
active
oldest
votes
The Turkish characters look fine. However grep has inserted colour codes into the output.
Choices:
- add option
--color=never
to grep (to remove colour). - add option
-R
to less (to tell less to interpret ASCII colour codes).
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498414%2fpossible-inconsistent-behavior-of-grep-and-less%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Turkish characters look fine. However grep has inserted colour codes into the output.
Choices:
- add option
--color=never
to grep (to remove colour). - add option
-R
to less (to tell less to interpret ASCII colour codes).
add a comment |
The Turkish characters look fine. However grep has inserted colour codes into the output.
Choices:
- add option
--color=never
to grep (to remove colour). - add option
-R
to less (to tell less to interpret ASCII colour codes).
add a comment |
The Turkish characters look fine. However grep has inserted colour codes into the output.
Choices:
- add option
--color=never
to grep (to remove colour). - add option
-R
to less (to tell less to interpret ASCII colour codes).
The Turkish characters look fine. However grep has inserted colour codes into the output.
Choices:
- add option
--color=never
to grep (to remove colour). - add option
-R
to less (to tell less to interpret ASCII colour codes).
answered Feb 3 at 13:37
ctrl-alt-delorctrl-alt-delor
11.7k42159
11.7k42159
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f498414%2fpossible-inconsistent-behavior-of-grep-and-less%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I guess (s)he meant the Turkish characters are not appeared in the second example as he seeks and this is a problem @Kusalananda
– zwlayer
Feb 3 at 10:43
@zwlayer Oh, I saw
EMİROĞLU
and thought that was the expected output.– Kusalananda
Feb 3 at 10:46
@Kusalananda Yup,
EMİROĞLU
is the part of the expected output. But I guess problem occurs in the second part of that output where (s)he getsESC[1;35;40mESC[KEmirESC[mESC[Koğlu
instead ofEmiroğlu
– zwlayer
Feb 3 at 10:50
1
Your
grep
is using terminal control sequences to highlight (color) the matched string, whichless
does not understand by default. Look for agrep
option to turn off coloring (in GNU--color=never
or--color=auto
) or useless -R
to tell it to understand terminal coloring. If you (want to) use these a lot you may want to make them aliases or functions in your shell profile.– dave_thompson_085
Feb 3 at 11:19