Browse Source

grep info 1

master
zeus 4 years ago
parent
commit
84db863625
  1. 6
      grep/2_Displaying_matched_pattern/code
  2. 3
      grep/2_Displaying_matched_pattern/codeanswer
  3. 2
      grep/2_Displaying_matched_pattern/info
  4. 9
      grep/2_Displaying_matched_pattern/q-info

6
grep/2_Displaying_matched_pattern/code

@ -1,8 +1,14 @@
echo "Inverting the pattern match"
grep -v "Jordan" $LLO_DATAFILE | head 5
echo "Matching the lines that start with a string"
grep -n "^Mi" $LLO_DATAFILE | tail -5
echo "Matching the lines that end with a string"
grep -n "15$" $LLO_DATAFILE | tail -5
echo "Checking for the whole words in a file"
grep -w "Jordan" $LLO_DATAFILE | tail -5
echo "Displaying only the matched pattern"
grep -o "Jordan" $LLO_DATAFILE | tail -5

3
grep/2_Displaying_matched_pattern/codeanswer

@ -1 +1,2 @@
grep -Hns "Jordan" $LLO_DATAFILE | grep -o Ed | head -15
grep "Jordan" $LLO_DATAFILE | grep -v Edd | grep Michae | grep 199[0,1,2]

2
grep/2_Displaying_matched_pattern/info

@ -8,6 +8,8 @@ By default, grep matches the given string/pattern if it found as a substring in
- The *^* regular expression pattern specifies the start of a line. This can be used in grep to match the lines which start with the given string or pattern.
- The *$* regular expression pattern specifies the end of a line. This can be used in grep to match the lines which end with the given string or pattern.
[INFO]
====

9
grep/2_Displaying_matched_pattern/q-info

@ -1,9 +1,2 @@
Try to run
[source,sh]
----
grep -Hns "jordan" $LLO_DATAFILE | grep -v Eddie
----
and see the Results!
Try to find Michael Jordan statistics for 1991,2,3

Loading…
Cancel
Save