How can I show the contents of a text file, with every occurrence of a word highlighted?
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.
93586
These should work by adding spaces or removing spaces from the beginning of the current line or every line between the start and end of a text selection (inclusive).  (edited this question to supplement )
9019
What's a good way of extracting say, lines 20 -45 out of a huge text file. Non-interactively of course!
31558
How do you iterate through every file/directory recursively in standard C++?
42775
I had a command which would work through a text file, count all the occurrences of the words and print it out like this:  user@box $˜ magic-command-i-forgot | with grep | and awk | sort ./textfile.txt 66: the 54: and 32: I 16: unix 12: bash 5:  internet 3:  sh 1: GNU/Linux   So it does not search line-by-line, but word by word, and it does it for all the words, not just for 1 word. I'd found it somewhere on the internets a long time ago, but I cannot find or remember it..
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?
55508
I would like to find out the number of occurrences of each of the alphabets in a word. Eg  input  aabbbddd    output  a@2 b@3 c@0 d@3   How can I perform this using shell script?
41776
I'm sure there are many ways to do this: how can I count the number of lines in a text file?  $ &lt;cmd&gt; file.txt 1020 lines
17935
I have a file formatted like this:  train/t/temple/east_asia/00000025.jpg 94 train/t/temple/east_asia/00000865.jpg 94 ... train/s/swamp/00000560.jpg 92 train/s/swamp/00000935.jpg 92 .... train/m/mountain/00000428.jpg 68 train/m/mountain/00000126.jpg 68   The last number is the class number. I have 50 different classes, and each class has 1,000 lines. I would like to take a random sample of size N from each class, and store the result in another text file.
29342
Within a set of directories, how do I find a file whose name includes a given string, such as "abcde"?
76162
In a long, long, long writing. I have a piece of text that repeats in several places/sections/chapters. When I'm editing, I change 2 or 3 words in that piece of text. The changes have to be applied to all its repetitions in the document. The question is, how can I automate this?  The solution I'm looking for would be something like:  Lorem ipsum \textthatrepeatselsehwhere{This text will be shown in several places}\label{textrep1} lorem ipsum.  Lorem ipsum \displaytextoflabel{textrep1} lorem lorem.   The output should look like:     Lorem ipsum This text will be shown in several places lorem ipsum.      Lorem ipsum This text will be shown in several places lorem lorem.   The solution might be obvious but I don't know how to do it. Thanks, any help will be appreciated.
22744
Is there a way to save all my typed terminal commands and view it like history in a log book?
35540
I have a file with many rows, and each row has a timestamp at the starting, like  [Thread-3] (21/09/12 06:17:38:672) logged message from code.....   So, I frequently check 2 things from this log file.   First few rows, that has the global conditions and start time is also given. Last few rows, that has the exit status with some other info.   Is there any quick handy single command that could let me display just the first and last few lines of a file?
113304
I have:  Name PhoneNo JOHN 555555 JOHN 555554 MIKE 111111 MIKE 122222   I want to display output like:  Name PhoneNo JOHN 555555      555554 MIKE 111111      111112
20524
What is the best way to write data to the text console at arbitrary locations on the screen and with custom fore/background colors?
110365
I have a file contains around million number of lines. In the lines I have a field called transactionid, which has repetitive values. What I need to do is to count them distinctly.  No matter of how many times a value is repeated, it should be counted only once.
94554
Similar to the \dotfill command, but with your own text, rather than dots.  If the string was: kitty!  The entire line would look like the following: kitty!kitty!kitty!kitty!kitty!kitty!kitty!kitty!kitty!  Is there any way to do this?