Skip to main content
added 4 characters in body
Source Link
$cat contents.txt

cat-1.15

cat-1.15

cat-1.15
cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15
cat-1.15
cat-1.15
cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

$cat contents

cat-1.15

cat-1.15

cat-1.15
cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15
cat-1.15
cat-1.15
cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

$cat contents.txt

cat-1.15

cat-1.15

cat-1.15
cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15
cat-1.15
cat-1.15
cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

added 52 characters in body
Source Link
jesse_b
  • 41.5k
  • 14
  • 108
  • 162

$cat contents cat-1.15

cat-1.15

cat-1.15 cat-1.18

$cat contents

cat-1.15

cat-1.15

cat-1.15
cat-1.18

The above output has blank lines

$cat contents.txt | grep cat$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15 cat-1.15 cat-1.15 cat-1.18

cat-1.15
cat-1.15
cat-1.15
cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

$cat contents cat-1.15

cat-1.15

cat-1.15 cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15 cat-1.15 cat-1.15 cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

$cat contents

cat-1.15

cat-1.15

cat-1.15
cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15
cat-1.15
cat-1.15
cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?

Source Link

highlight a word without affecting the structure of text

$cat contents cat-1.15

cat-1.15

cat-1.15 cat-1.18

The above output has blank lines

$cat contents.txt | grep cat results in the word cat being highlighted, but the resultant text is also merged, eliminating blank lines

cat-1.15 cat-1.15 cat-1.15 cat-1.18

How can I grep to highlight without grep affecting the text structure, so that the only difference is the grep term being highlighted ?