The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 2,743β€…    Votes:  6β€…
Tags: command-line   grep   ls   pipe  
Link: πŸ” See Original Answer on Ask Ubuntu πŸ”—

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: November 24, 2022    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:

Color output

color ls

⇧ What happend to SMART data (disk selftest option) Is Ubuntu Server required for LAMP server or will anything break if I install LAMP on Ubuntu Desktop?  β‡©