Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with total line in exercise #78

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions _episodes/02-counting-mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,18 +281,18 @@ programming languages.
>{: .bash}
>
>
>Now let's change the scenario. Imagine that we have a directory containing 100 `csv` files. We want to know the 10 files that contain the most words. Fill in the blanks below to count the words for each file, put them into order, and then make an output of the 10 files with the most words (Hint: The sort command sorts in ascending order by default).
>Now let's change the scenario. Imagine that we have a directory containing 100 `csv` files. We want to know the 10 files that contain the most words. Fill in the blanks below to count the words for each file, put them into order, and then make an output of the 10 files with the most words. `wc` prints a line showing the total number of words. You will need to remove this from the output. (Hint: The sort command sorts in ascending order by default).
>
>~~~
>__ -w *.csv | sort | ____
>__ -w *.csv | sort -n | ____ | ____
>~~~
>{: .bash}
>
> > ## Solution
> >
> > Here we use the `wc` command with the `-w` (word) flag on all `csv` files, `sort` them and then output the last 10 lines using the `tail` command.
> > Here we use the `wc` command with the `-w` (word) flag on all `csv` files, `sort` them and then output the last 11 lines using the `tail` command. This will include the total line (which is always printed last), so we extract the first 10 lines of the file to remove it.
> >~~~
> > wc -w *.csv | sort | tail -n 10
> > wc -w *.csv | sort -n | tail -n 11 |head -n 10
> >~~~
> {: .solution}
>{: .bash}
Expand Down