Views:
2,859β
Votes: 6β
Tags:
command-line
grep
ls
pipe
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/865249
Title:
Why the pipe command "l | grep "1" " get the wrong result?
ID:
/2016/12/28/Why-the-pipe-command-_l-_-grep-_1_-_-get-the-wrong-result_
Created:
December 28, 2016
Edited: December 28, 2016
Upload:
December 22, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
Your l
and ls
commands are setup as aliases.
When you run them piping the output through grep "1"
(using |
) each screen line where 1
appears is displayed, with the 1
colored red.
Because file names .
, ..
, 2
and 22
appear on the same screen line, they are output by grep
as well but do not appear in red which shows grep
matches.
The :34m
is an escape sequence for a color that doesnβt paint properly. Based on your revised question with the output of type -a l
and type -a
it can be reproduced in my system. Please note you should change your alias from --color
to --color=auto
: