How to do it...

We have already seen most of these concepts already and even wc itself in one of the previous recipes, so let's get started:

  1. Open a terminal and run the following commands:
$ wc -l testdata/duplicates.txt$ wc -c testdata/duplicates.txt
  1. As you may have noticed, the output has the filename included. Can we remove it with AWK? Absolutely, but we can also remove it with a command called cut. The -d flag stand, for delimiter and we would like to have a field (specified by -f1):
$ wc -c testdata/duplicates.txt | cut -d ' ' -f1$ wc -c testdata/duplicates.txt | awk '{ print $1 }'
  1. Imagine that we have a massive file full of strings. Could we reduce the returned results? Of course, but let's use the sort command first to sort the ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.