You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.4 KiB
76 lines
1.4 KiB
|
|
The grep understands three different types of regular expression syntax as follows:
|
|
|
|
- basic (BRE)
|
|
- extended (ERE)
|
|
- perl (PCRE)
|
|
|
|
|
|
Examples
|
|
|
|
The dot (.) matches any single character. You can match specific characters and character ranges using [..] syntax.
|
|
|
|
|
|
[source,sh]
|
|
----
|
|
grep "Jordan" $LLO_DATAFILE | grep "\,199.\,M"
|
|
----
|
|
|
|
INFO: You can escape the dot (.) by preceding it with a \ (backslash)
|
|
|
|
|
|
Say you want to Match both ‘Jordan’ or ‘jordan’:
|
|
|
|
[source,sh]
|
|
----
|
|
grep '[Jj]ordan' $LLO_DATAFILE
|
|
----
|
|
|
|
OR
|
|
|
|
[source,sh]
|
|
----
|
|
grep '[Jj][oO][rR][dD][aA][nN]' $LLO_DATAFILE
|
|
----
|
|
|
|
[source,sh]
|
|
----
|
|
grep '\<b.t\>' $LLO_DATAFILE
|
|
----
|
|
|
|
Where,
|
|
|
|
- \< Match the empty string at the beginning of word
|
|
- \> Match the empty string at the end of word.
|
|
|
|
|
|
Do *OR* with grep
|
|
|
|
[source,sh]
|
|
----
|
|
grep -E 'Michael Jordan|Eddie Jordan' $LLO_DATAFILE
|
|
----
|
|
|
|
Do *AND* with grep
|
|
|
|
[source,sh]
|
|
----
|
|
grep '199[0-9]' $LLO_DATAFILE | grep -E "Kukoc|Jordan"
|
|
----
|
|
|
|
|
|
[INFO]
|
|
====
|
|
|
|
DATAFILE
|
|
|
|
The datafile contains aggregate individual statistics for 67 NBA seasons. from basic box-score attributes such as points, assists, rebounds etc., to more advanced money-ball like features such as Value Over Replacement.
|
|
|
|
Take a look in
|
|
link:https://git.swarmlab.io:3000/llo/LabLearningObject/src/branch/master/data/nba_statistics_glossary[Glossary^]
|
|
for a detailed column description
|
|
|
|
ENVIRONMENT VARIABLE: LLO_DATAFILE
|
|
|
|
====
|
|
|
|
|