Questions tagged [highlighting]

52 questions
319
votes
23 answers

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I setup for a tail command that would help me do this?
Amir Afghani
  • 7,083
  • 11
  • 26
  • 23
160
votes
13 answers

Convince grep to output all lines, not just those with matches

Say I have the following file: $ cat test test line 1 test line 2 line without the search word another line without it test line 3 with two test words test line 4 By default, grep returns each line that contains the search term: $ grep test…
Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
50
votes
5 answers

How can I display syntax highlighting on a file?

Is there a variant of cat that outputs syntax-highlighted lines of code when used on a source file? An idea: maybe vi[m] or another editor can be asked to dump the syntax-highlighted contents of said files to stdout and exit immediately?
Paolo
  • 1,495
  • 2
  • 13
  • 8
18
votes
2 answers

How to highlight a word in the output of "cat"?

I can do the following to see if some word is available in the output of "cat": cat filename | grep word This filters the output and shows only those lines which contain "word". Now, is it possible to only highlight the "word" in the output,…
B Faley
  • 4,213
  • 11
  • 37
  • 48
17
votes
2 answers

Current date in cal is not highlighted in recent Debian

As answered in Highlight the current date in cal the current date in output form cal is automatically highlighted (reverse colors) if the output goes to terminal. That's what I had always been getting. However, with my current Debian GNU/Linux, it…
xpt
  • 1,182
  • 2
  • 13
  • 32
14
votes
7 answers

`highlight` command

Is there a command which can be used to easily highlight (with colors, bold text or inverted back-/foreground) specific strings in stdin while passing the entire string to stdout? I'm thinking of building it, but I'd rather just use it if it already…
l0b0
  • 50,672
  • 41
  • 197
  • 360
14
votes
4 answers

Command that highlights regex in text?

Is there a command that highlights a certain expression in text? I'm looking for something like the 'search' function in less, but with normal text output on stdout, instead of the less viewer. Example: $ cat test.txt | highlight "an" Prospects…
Frank
  • 2,771
  • 4
  • 17
  • 9
11
votes
4 answers

syntax_highlight | lpr

Does anyone know of a simple way to produce the PostScript corresponding to a syntax-highlighted version of a source file that can be piped directly to a PostScript printer? As the wording of the question above probably suggests, I'm looking for…
kjo
  • 14,779
  • 25
  • 69
  • 109
8
votes
7 answers

Highlight the current date in cal

I would like to highlight today's date in the output of the cal command. What is the best way? This is what I have so far: cal -m | grep -C6 --color "$(date +%e)" but it doesn't work for all cases e.g, when the date has a single digit. I also want…
dogbane
  • 29,087
  • 16
  • 80
  • 60
7
votes
1 answer

Highlight the current search match in man pages

When I open a man page, for example man chmod and I hit / for searching a string in the page I can see all the matching strings highlighted. Pressing n or N will focus on the next/previous matching string. Is there a way to highlight the current…
Leonardo
  • 173
  • 1
  • 4
6
votes
1 answer

Text editor with font-size selection for specific human languages (ie. Unicode Block) eg Devanagari

Pre Linux, I used Windows.. (too many years in the wilderness :) ... however there was a ray of sunshine in amongst all the general virus/re-install flack.. and that was Notepad++, a text Editor I really like(d). I'd probably still be using it,…
Peter.O
  • 32,426
  • 28
  • 115
  • 163
5
votes
1 answer

How to highlight entire line on matching a word within the line in egrep?

Currently, I use egrep --color 'error|$' to highlight every word in a line containing the word error: I would like to highlight the entire line though so that the entire string appears in red. How can I achieve that?
k0pernikus
  • 14,853
  • 21
  • 58
  • 79
5
votes
2 answers

Man page highlight color

To colorize my man pages, I put this code from archlinux.org into .bashrc: man() { env LESS_TERMCAP_mb=$'\E[01;31m' \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ LESS_TERMCAP_me=$'\E[0m' \ LESS_TERMCAP_se=$'\E[0m' \ …
bongbang
  • 541
  • 1
  • 6
  • 10
4
votes
4 answers

No syntax highlighting when editing crontab

I am trying to figure out why I don't have syntax highlighting when editing my crontab. I have both $EDITOR and $VISUAL set to /usr/bin/vim: > echo $EDITOR /usr/bin/vim > echo $VISUAL /usr/bin/vim If I save the crontab to a file and edit it with…
ben
  • 151
  • 1
  • 4
4
votes
1 answer

Retain selection highlight after copying text to clipboard in tmux

I'm using macOS and tmux 3.1c. When copying a text via mouse selection, the highlight will be auto-cleared after copying the text to clipboard, this will make it difficult to keep track the last line you copied when you go back to it: Is there a…
Ranel Padon
  • 143
  • 5
1
2 3 4