I need a command that colorizes some symbol sequence in output of a certain command. I'd like it like grep make it.  $ some-command | grep symbol-sequence   However grep removed lines that isn't contained symbol-sequence. I'd like to have all original lines with highlighted symbol-sequence. How it can be done?    I have alias grep='grep --color=auto' in ~/.bashrc
52623
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 test  test line 1 test line 2 test line 3 with two test words test line 4   Passing the --color parameter to grep will make it highlight the portion of the line that matches the search expression, but it still only returns lines that contain the expression. Is there a way to get grep to output every line in the source file, but highlight the matches?  My current terrible hack to accomplish this (at least on files that don't have 10000+ consecutive lines with no matches) is:  $ grep -B 9999 -A 9999 test test     If grep can't accomplish this, is there another command-line tool that offers the same functionality? I've fiddled with , but it doesn't seem to have an option for it either.
59233
All is in the title. I would like to add a color to the text before a character with listing package.  For example, I would like to add a color to text between the beginning of a line and : or =, in a makefile.  I tried to use moredelimiters but I did not succeed.    \documentclass{article}  \usepackage{listings} \usepackage{xcolor} \definecolor{keycolor}{RGB}{172, 42, 42} \definecolor{mbleu}{RGB}{64,96,127} \definecolor{vimvert}{RGB}{46, 139, 87}  \lstdefinestyle{global}{   basicstyle=\ttfamily\scriptsize\color{black!90},%   stringstyle=\itshape\color{magenta},%   showstringspaces=false,%   keywordstyle={\bfseries\color{keycolor}},%   commentstyle=\color{blue}\slshape,%   framexleftmargin=1mm,%   backgroundcolor=\color{black!2},% }  \lstdefinestyle{makefile}{   style=global,%   morecomment=[l][commentstyle]{\#},%   emphstyle={\color{vimvert}},%   moredelim=[s][emphstyle]{\$(}{)}% }  \begin{document}  \begin{lstlisting}[style=makefile] .SUFFIXES: .inc .f .f90 .F  # all CPP processed fortran files have the extension .f90 SUFFIX=.f90  #----------------------------------------------------------------------- # this release should be fpp clean # we now recommend fpp as preprocessor # if this fails go back to cpp CPP_=fpp -f_com=no -free -w0 $*.F $*$(SUFFIX)  vasp: $(SOURCE) $(FFT3D) $(INC) main.o      rm -f vasp     $(FCL) -o vasp main.o  $(SOURCE)   $(FFT3D) $(LIB) $(LINK) makeparam: $(SOURCE) $(FFT3D) makeparam.o main.F $(INC)     $(FCL) -o makeparam  $(LINK) makeparam.o $(SOURCE) $(FFT3D) $(LIB) zgemmtest: zgemmtest.o base.o random.o $(INC)     $(FCL) -o zgemmtest $(LINK) zgemmtest.o random.o base.o $(LIB) dgemmtest: dgemmtest.o base.o random.o $(INC)     $(FCL) -o dgemmtest $(LINK) dgemmtest.o random.o base.o $(LIB)  ffttest: base.o smart_allocate.o mpi.o mgrid.o random.o ffttest.o $(FFT3D) $(INC)     $(FCL) -o ffttest $(LINK) ffttest.o mpi.o mgrid.o random.o smart_allocate.o base.o $(FFT3D) $(LIB) kpoints: $(SOURCE) $(FFT3D) makekpoints.o main.F $(INC)     $(FCL) -o kpoints $(LINK) makekpoints.o $(SOURCE) $(FFT3D) $(LIB)  clean:       -rm -f *.g *.f *.o *.L *.mod ; touch *.F \end{lstlisting}  \end{document}
22476
I've just been fooling around with some code in C, an example of a really basic program is as follows which just, obviously, lists the directories using the ls system command.  #include &lt;stdio.h&gt;  int main (void) {     system("ls -l -d */");     printf("I've just listed the directories :-)\n");     return 0; }   This runs fine, but it shows the ls output in monochrome, whereas Bash would output the list using colors for the directories (or files if I included files). How can I make my C code use the bash colors? Thanks
116894
I want to run a command before and after every single command that gets executed in a terminal (i.e. clear before and then reset). I want this to happen automatically and not with a short alias or similar.  I have looked into bashrc and /usr/share/bash-completion/bash_completion although the latter seems to be just for the auto completion feature with the Tab?   Where should I make my changes?
19642
Is there a grep-like utility that will enable me to do grep searches with logic operators. I want to be able to nest and combine the logical constructs freely. For example, stuff like this should be possible:  grep (term1 &amp;&amp; term2) || (term1 &amp;&amp; (term3 xor term4)) *   I realize this can be done with vanilla grep and additional bash scripting, but my goal here is to avoid having to do that.
119999
I wanted to give my terminal prompt in Ubuntu a more personal look, and wanted to change the text prior to the '$' when writing a command.  From what I've found this is done by editing the .bashrc file in the home directory, so I went in there and changed  if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi   to  if [ "$color_prompt" = yes ]; then     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else     PS1='\e[1;32m[\W]\$ \e[m' fi   This works and the terminal looks the way I want it to.  But after some time when entering a couple of commands when I use the arrow-up key to get to the command history, things get weird.  From a clean line and pressing the arrow-up key is works. When pressing it again the text that was on the line gets capped at about ~15 characters and the new command in the history (that is supposed to be displayed) gets capped by a few characters in the beginning, and they are sort of merged together on the command line.  E.g. my two most recent commands are  Java Test4 words-250.txt words-250-in.txt Javac Test4.java   When pressing the arrow-up key once, the first line is displayed, as it should. When pressing it a second time, this is displayed:  Java Test4 worc Test4.java   Despite this weird output, the terminal works fine. If for instance I press enter after doing the above, Javac Test4.java will run. If I instead try to delete the entire line using backspace, I am only able to delete up until the line says  Java Test4   and if pressing enter after that I get a new empty line, just as if the line was empty when pressing enter.  All of this goes away if I reset the .bashrc file.  Why does this happen and how can I fix it?
106954
When a script runs, commands in it may output some text to stdout/stderr. Bash itself may also output some text.  But if a few scripts are running at the same time, it is hard to identify where does an error come from.  So is it possible to insert a prefix to all output of the script? Something like:  #!/bin/bash prefix 'PREFIX' &amp;2 echo "wrong!" &gt;&amp;2   Then:  $ ./script.sh PREFIXwrong!
34984
I am starting to learn some Regex, therefore I use this command repeatedly:  grep pattern /usr/share/dict/american-english    Only the part with pattern changes, so I have to write the long expression "/usr/share/dict/american-english" again and again.   Someone made the remark that it is possible to expand an argument of a command from the command history by typing cryptic character combinations instead of the full expression.  Could you tell me those cryptic character combinations ?
33328
I notice a lot of bash utilities like ls, cp, mv, grep use regular expressions and pattern matching. For instance symbols like * [] {} etc.   However, I find this to be different in some regard to other regular expression tutorials I find on the Internet. Is there a specific standard that these utilities follow or a comprehensive list of shortcuts somewhere?   Thank you
50320
What can I type at my shell (which happens to be bash) that will list all the commands that are recognized?  Also, does this differ by shell? Or do all shells just have a "directory" of commands they recognize?  Secondly, different question, but how can I override any of those? In other words how can I write my own view command to replace the one existing on my Ubuntu system, which appears to just load vim.
6653
Suppose I want to execute a sequence of four commands that I have executed before. If the first one is 432 in the command-history, then I could do:  $ !432; !433; !434; !435   I'm curious, is there a more efficient way to accomplish this?
26646
I need  to use the less command with the syntax highlighting of the vim command for python, C, bash and other languages.  How do I apply syntax highlighting colors according to vim colors for less command?
35837
Many command-line tools (grep, flex, etc.) use the ^ symbol to denote "beginning of line" and the $ symbol to denote "end of line." When did this convention arise? It seems perfectly reasonable to reserve two characters for these purposes, but it's a bit odd that on modern keyboards the $ symbol is to the left of the ^ symbol.  Is this a completely arbitrary decision? Does this come from some older keyboard layout? Is this convention used because some older tool decided to do things this way?  Regardless of the answer, are there primary sources that document this?
73683
Short question:  Using bash, is it possible to print a sentence such that each individual word has a different color?   I.e; print a word in-line, change the text color, repeat?
105906
I have a custom PS1 colour where I have the actual shell commands in a distinct colour, just so I can quickly see what commands I typed and separate it from the command output itself.  Suppose the colour in PS1 is set to 'blue' for command prompt and the default colour in my shell is white.    I type a command e.g. ls, (ls -l is coloured blue) The output it generates, first line is still blue All remaining line comes as white   What I want is all the output after the command to be 'white'.  Another example:   I type a command 'cat ', colour is blue The output comes, the whole output is blue   I would like the output to be 'white' while keeping the command prompt I typed 'blue'  On some commands, it is fine, other commands, the same colour overflows into the first line of the output and then the default colour kicks in and some other commands, the whole output (e.g. cat) has the same colour.   Is there a way to keep just the commands I typed in one colour and the rest to the default?  I'm on OSX.  EDIT #1  Here's a screenshot that @derobert's linked to in the comments that shows what I'm looking for.  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
98896
I'm trying to pipe the output of a grep search into the input of another grep. Such as:  grep search_query * | grep -v but_not_this   But the second grep is not using the output of the previous search. It looks like the second grep is just using * instead. For example,  grep lcov *                                                                                           tst/bits/Module.mk:21:$(call func_report_lcov) tst/drivers/Module.mk:27:$(call func_report_lcov)   But when I want to filter out the results containing "call",  grep lcov * | grep -v call ...   Grep gives me every single line in my workspace that doesn't contain "call".  Environment Info:   This is happening in both bash and fish I have aliased the grep command like so alias grep='grep -nR --color=always'   Anything else I might be missing?
33813
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, without dropping other lines?