Giter VIP home page Giter VIP logo

hl's Introduction

date section title
February 9, 2022
1
HL

NAME

hl - read and highlight regular expression matches

SYNOPSIS

hl pattern

hl [--ansi attribute] [--buffer] pattern

hl [--ansi attribute] [--no-buffer] pattern

DESCRIPTION

The hl utility copies standard input to standard output, highlighting lines that match pattern, which must be a valid regular expression. The optional command line arguments are as follows:

--ansi attribute
Highlights pattern matches using the ANSI code corresponding to attribute.

By default, hl uses ANSI codes to embolden text to highlight match text, and non-bold text for all other text. Other ANSI codes are supported as shown in the below table. Several rows contain multiple attributes, indicating they are intended synonyms.

attribute ANSI code
----------------------- ---------
bold ESC[1m
dim|faint ESC[2m
italic ESC[3m
underline|underscore ESC[4m
blinking ESC[5m
reverse|inverse ESC[7m
hidden|invisible ESC[8m
strikethrough ESC[9m
black ESC[30m
red ESC[31m
green ESC[32m
yellow ESC[33m
blue ESC[34m
magenta ESC[35m
cyan ESC[36m
white ESC[37m

NOTE: Not all ANSI codes work on every terminal.

--buffer
Buffers its output even when it detects that it is writing to a character device.

By default when hl detects that its standard output is directed to a character device, like a TTY, it will write each line of output immediately after processing it. However, if hl detects that its standard output is not directed to a character device, for instance when it is being piped into another process, it will use a small memory buffer to reduce the number of system write calls it makes. However, when given the --buffer command line flag, hl will buffer its output even when it detects that it is writing to a character device.

--no-buffer
Does not buffer its output even when its output is not a character device. Use this when piping the output of hl to another process, and each complete line should be flushed immedidately after it is processed.

EXIT VALUES

0
Success

1
Syntax or usage error

2
Error reading input

3
Error writing output

EXAMPLES

Example 1: Highlighting a text pattern from a stream
This example tails a file and highlights any instances of the word failure using a bold typeface:

# tail -f /var/log/messages | hl failure

Example 2: Highlighting multiple patterns from a stream
hl invocations may be chained together to highlight multiple patterns using different ANSI codes. When doing so, it is common to turn off buffering in every instance of hl that pipes its output to another program. This example will tail a file and highlight BAD with red, and OK with green.

# tail -f /var/log/messages | hl --ansi red --no-buffer BAD | hl --ansi green OK

AUTHORS

Karrick McDermott https://linkedin.com/in/karrick

hl's People

Watchers

Karrick McDermott avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.