Browse Source

cut field

master
zeus 4 years ago
parent
commit
1b6e847d34
  1. 15
      cut/2_Cutting_Field/code
  2. 1
      cut/2_Cutting_Field/codeanswer
  3. 6
      cut/2_Cutting_Field/codehelp
  4. 24692
      cut/2_Cutting_Field/data
  5. 33
      cut/2_Cutting_Field/info
  6. 9
      cut/2_Cutting_Field/q-info
  7. 23
      index_cut.yml

15
cut/2_Cutting_Field/code

@ -0,0 +1,15 @@
echo "Cutting Contents of a file on the standard output (stdout)."
echo "-----with fields-----"
echo ""
echo "field 5"
cut -d',' -f5 $LLO_DATAFILE | head -5
echo ""
echo "field 8,13"
cut -d',' -f8,13 $LLO_DATAFILE | head -5
echo ""
echo "field 8-10"
cut -d',' -f8-10 $LLO_DATAFILE | head -5

1
cut/2_Cutting_Field/codeanswer

@ -0,0 +1 @@
cut -d',' -f8,13 $LLO_DATAFILE | grep "[A-Z,a-z]" | head -5

6
cut/2_Cutting_Field/codehelp

@ -0,0 +1,6 @@
-d option is used then it considered ',' as a field separator or delimiter
grep with regex (see grep)

24692
cut/2_Cutting_Field/data

File diff suppressed because it is too large

33
cut/2_Cutting_Field/info

@ -0,0 +1,33 @@
*-f(field):* To extract the specific field.
*-c* option is useful for fixed-length lines.
Most files doesn’t have fixed-length lines.
To extract information you need to cut by fields.
List of the fields must be separated by -d option.
[source,bash]
----
cut -d',' -f5 $LLO_DATAFILE | head -5
----
[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
cut/2_Cutting_Field/q-info

@ -0,0 +1,9 @@
Try to run
[source,sh]
----
cut -d',' -f8,13 $LLO_DATAFILE | grep "[A-Z,a-z]" | head -5
----
and see the Results!

23
index_cut.yml

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

Loading…
Cancel
Save