Source file ⇒ Lab_9.Rmd

Using egrep

Get the rows for:

no_jedi

input: egrep no_jedi stars.csv

male

input: egrep [^fe]male stars.csv

Create a new file blaster.csv containing those individuals with weapon blaster:

input: egrep blaster stars.csv > blaster.csv

Select name and height, and sort lines by height:

input: cut -f 1,3 -d ‘,’ stars.csv | tail -20 | sort -k 2 -t ‘,’

output:

Yoda,0.66
R2-D2,0.96
Chief Chirpa,1
Leia Skywalker,1.5
Padme Amidala,1.65
C-3PO,1.67
Luke Skywalker,1.72
Sheev Palpatine,1.73
Darth Maul,1.75
Lando Calrissian,1.78
Han Solo,1.8
Obi-Wan Kenobi,1.82
Boba Fett,1.83
Jango Fett,1.83
Anakin Skywalker,1.88
Dooku,1.93
Qui-Gon Jinn,1.93
Grievous,2.16
Chewbacca,2.28
Jabba,3.9

To Turn In

how many humans

input: cut -f 12 -d ‘,’ stars.csv | egrep human | uniq -c

output:

 12 human
 

how many jedis

input: egrep [^_]jedi stars.csv | tail -6 | cut -f 11 -d “,” | uniq -c

output:

 6 jedi
 

names of jedis

input: egrep [^_]jedi stars.csv | cut -f 1 -d ‘,’ | tail -6

output:

Anakin Skywalker
Luke Skywalker
Qui-Gon Jinn
Obi-Wan Kenobi
Yoda
Dooku

names of jedis in alphabetical order

input: egrep [^_]jedi stars.csv | cut -f 1 -d ‘,’ | tail -6| sort

output:

Anakin Skywalker
Dooku
Luke Skywalker
Obi-Wan Kenobi
Qui-Gon Jinn
Yoda

table of frequencies for weapons

input: cut -f 13 -d ‘,’ stars.csv | tail -20 | sort | uniq -c

output:

  5 blaster
  1 bowcaster
  1 force-lightning
  7 lightsaber
  1 slugthrower
  1 spear
  4 unarmed

table of frequencies for weapons in decreasing order

input: cut -f 13 -d ‘,’ stars.csv | tail -20 | sort | uniq -c | sort -r

output:

  7 lightsaber
  5 blaster
  4 unarmed
  1 spear
  1 slugthrower
  1 force-lightning
  1 bowcaster