You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 5, 2024. It is now read-only.
@@ -1408,6 +1426,7 @@ $ man grep | sed -n '/^\s*-P/,/^$/p'
1408
1426
```
1409
1427
1410
1428
* The man page informs that `-P` is *highly experimental*. So far, haven't faced any issues. But do keep this in mind.
1429
+
* newer versions of `GNU grep` has fixes for some `-P` bugs, see [release notes](https://savannah.gnu.org/news/?group_id=67) for an overview of changes between versions
1411
1430
* Only a few highlights is presented here
1412
1431
* For more info
1413
1432
* `man pcrepattern` or [read it online](https://www.pcre.org/original/doc/html/pcrepattern.html)
@@ -1733,10 +1752,10 @@ real 0m0.008s
1733
1752
* `*` match preceding character/group 0 or more times
1734
1753
* `+` match preceding character/group 1 or more times
1735
1754
* `?` match preceding character/group 0 or 1 times
1755
+
* `{m,n}` match preceding character/group m to n times, including m and n
1756
+
* `{m,}` match preceding character/group m or more times
1757
+
* `{,n}` match preceding character/group 0 to n times
1736
1758
* `{n}` match preceding character/group exactly n times
1737
-
* `{n,}` match preceding character/group n or more times
1738
-
* `{n,m}` match preceding character/group n to m times, including n and m
1739
-
* `{,m}` match preceding character/group up to m times
1740
1759
1741
1760
<br>
1742
1761
@@ -1764,8 +1783,7 @@ real 0m0.008s
1764
1783
1765
1784
#### <a name="basic-vs-extended-regular-expressions"></a>Basic vs Extended Regular Expressions
1766
1785
1767
-
By default, the pattern passed to `grep` is treated as Basic Regular Expressions(BRE), which can be overridden using options like `-E` for ERE and `-P` for Perl Compatible Regular Expression(PCRE)
1768
-
Paraphrasing from `info grep`
1786
+
By default, the pattern passed to `grep` is treated as Basic Regular Expressions(BRE), which can be overridden using options like `-E` for ERE and `-P` for Perl Compatible Regular Expression(PCRE). Paraphrasing from `info grep`
1769
1787
1770
1788
>In Basic Regular Expressions the meta-characters `? + { | ( )` lose their special meaning, instead use the backslashed versions `\? \+ \{ \| \( \)`
1771
1789
@@ -1776,22 +1794,24 @@ Paraphrasing from `info grep`
1776
1794
* `man grep` and `info grep`
1777
1795
* At least go through all options ;)
1778
1796
* **Usage section** in `info grep` has good examples as well
1797
+
* This chapter has also been [converted to a book](https://github.com/learnbyexample/learn_gnugrep_ripgrep) with additional examples, exercises and covers popular alternative `ripgrep`
1779
1798
* A bit of history
1799
+
* [Brian Kernighan remembers the origins of grep](https://thenewstack.io/brian-kernighan-remembers-the-origins-of-grep/)
1780
1800
* [how grep command was born](https://medium.com/@rualthanzauva/grep-was-a-private-command-of-mine-for-quite-a-while-before-i-made-it-public-ken-thompson-a40e24a5ef48)
1781
1801
* [why GNU grep is fast](https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html)
1782
1802
* [unix.stackexchange - Difference between grep, egrep and fgrep](https://unix.stackexchange.com/questions/17949/what-is-the-difference-between-grep-egrep-and-fgrep)
0 commit comments