Browse Source

grep info

master
zeus 4 years ago
parent
commit
62c2f1edf4
  1. 8
      grep/2_Displaying_matched_pattern/code
  2. 1
      grep/2_Displaying_matched_pattern/codeanswer
  3. 1
      grep/2_Displaying_matched_pattern/codehelp
  4. 24692
      grep/2_Displaying_matched_pattern/data
  5. 25
      grep/2_Displaying_matched_pattern/info
  6. 9
      grep/2_Displaying_matched_pattern/q-info
  7. 23
      index_grep.yml

8
grep/2_Displaying_matched_pattern/code

@ -0,0 +1,8 @@
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 "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

1
grep/2_Displaying_matched_pattern/codeanswer

@ -0,0 +1 @@
grep -Hns "Jordan" $LLO_DATAFILE | grep -o Ed | head -15

1
grep/2_Displaying_matched_pattern/codehelp

@ -0,0 +1 @@
grep -Hns "Jordan" $LLO_DATAFILE | grep -v Edie | head -1

24692
grep/2_Displaying_matched_pattern/data

File diff suppressed because it is too large

25
grep/2_Displaying_matched_pattern/info

@ -0,0 +1,25 @@
By default, grep matches the given string/pattern if it found as a substring in a file.
- You can display the lines that are not matched with the specified search sting pattern using the *-v* option.
- The *-w* option to grep makes it match only the whole words.
- We can make the grep to display only the matched string by using the *-o* option.
- 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.
[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
====

9
grep/2_Displaying_matched_pattern/q-info

@ -0,0 +1,9 @@
Try to run
[source,sh]
----
grep -Hns "jordan" $LLO_DATAFILE | grep -v Eddie
----
and see the Results!

23
index_grep.yml

@ -49,3 +49,26 @@
points: "" # ELO
output:
log: "bash"
2_Displaying_matched_pattern:
display_name: "Displaying_matched_pattern"
swarmlabservice: "os2"
info:
file: "2_Displaying_matched_pattern/info"
code:
lang: "bash"
exec: "/bin/bash"
file: "2_Displaying_matched_pattern/code"
data: "2_Displaying_matched_pattern/data"
options: ""
mimetype: "bash"
output:
log: "console"
mimetype: "bash"
challenge:
question: "2_Displaying_matched_pattern/q-info"
codehelp: "2_Displaying_matched_pattern/codehelp"
codeanswer: "2_Displaying_matched_pattern/codeanswer"
mimetype: "bash"
points: "" # ELO
output:
log: "bash"

Loading…
Cancel
Save