Added command to highlight numbers in a text

This commit is contained in:
Michele Cereda
2023-02-25 18:44:50 +01:00
parent afd085487e
commit 62b9faa684

View File

@@ -3,20 +3,23 @@
## TL;DR
```sh
# base search
grep 'pattern' path/to/search
# Basic search.
grep 'pattern' 'path/to/search'
# recursive search
grep -R 'pattern' path/to/search/recursively
grep -R --exclude-dir excluded/dir 'pattern' path/to/search/recursively # gnu grep >= 2.5.2
# Search recursively.
grep -R 'pattern' 'path/to/search/recursively'
grep -R --exclude-dir 'excluded/dir' 'pattern' 'path/to/search/recursively' # gnu grep >= 2.5.2
# show line numbers
grep -n 'pattern' path/to/search
# Show line numbers.
grep -n 'pattern' 'path/to/search'
# parallel execution
# mind the files with spaces in their name
find . -type f | parallel -j 100% grep 'pattern'
find . -type f -print0 | xargs -0 -n 1 -P $(nproc) grep 'pattern'
# Multiple parallel searches.
# Mind files with spaces in their name.
find . -type f | parallel -j +100% grep 'pattern'
find . -type f -print0 | xargs -0 -n 1 -P "$(nproc)" grep 'pattern'
# Highlight numbers in strings.
grep --color '[[:digit:]]' 'file.txt'
```
## Grep variants