diff --git a/grep/2_Displaying_matched_pattern/code b/grep/2_Displaying_matched_pattern/code index 8d198af..39ba414 100644 --- a/grep/2_Displaying_matched_pattern/code +++ b/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 diff --git a/grep/2_Displaying_matched_pattern/codeanswer b/grep/2_Displaying_matched_pattern/codeanswer index ea56dc9..10e0f37 100644 --- a/grep/2_Displaying_matched_pattern/codeanswer +++ b/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] diff --git a/grep/2_Displaying_matched_pattern/info b/grep/2_Displaying_matched_pattern/info index cc3af66..ce82d81 100644 --- a/grep/2_Displaying_matched_pattern/info +++ b/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] ==== diff --git a/grep/2_Displaying_matched_pattern/q-info b/grep/2_Displaying_matched_pattern/q-info index dd555b7..0d711a5 100644 --- a/grep/2_Displaying_matched_pattern/q-info +++ b/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