NULL
tr
is a command that replaces one character with another%%bash
is used to enter unix shell commandsExample: Converting Water into Wine
%%bash
echo "water" | tr 'a' 'i' | tr 't' 'n' | tr 'r' '.'
wine.
Using the example above AND the unix section of lecture 1 (or google), print string from table.txt
that satisfies the following, in the order presented below:
COUNT > 10
SOURCE
SOURCE
for the ID with the largest VALUE
The output should be presented as two lines, with a single number on each line.
* Hint: use man
to view all options for sort
* Don't forget to remove the header.
* Your code will be evaluated. We know you can figure it out on your own, but future examples won't be this simple!
* Bonus: can you get the solution in 2 lines?
%%bash
echo "ID COUNT VALUE QUANTITY SOURCE" > table.txt
echo "a 11 100 200 alAskA" >> table.txt
echo "d 90 200 600 Indonesia" >> table.txt
echo "c 10 500 700 LouIsianA" >> table.txt
echo "q 78 1 822 AntArctica" >> table.txt
echo "z 500 70 800 oNtariO" >> table.txt
# Hit print to view the table.txt file.
# Edit the text below this point to create your solution
# presented to students
cat table.txt
# jamison's one line solution
# expected result =
# 0
# 3
ID COUNT VALUE QUANTITY SOURCE a 11 100 200 alAskA d 90 200 600 Indonesia c 10 500 700 LouIsianA q 78 1 822 AntArctica z 500 70 800 oNtariO 0 3
awk
, sed
, and regular expressions ("regexes").