From 84db8636254f9f0288f5b62d562d0269cfc1d4cf Mon Sep 17 00:00:00 2001 From: zeus Date: Thu, 24 Sep 2020 21:39:40 +0300 Subject: [PATCH] grep info 1 --- grep/2_Displaying_matched_pattern/code | 6 ++++++ grep/2_Displaying_matched_pattern/codeanswer | 3 ++- grep/2_Displaying_matched_pattern/info | 2 ++ grep/2_Displaying_matched_pattern/q-info | 9 +-------- 4 files changed, 11 insertions(+), 9 deletions(-) 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