APPENDIX CUseful Unix Commands

Regardless of the operating system you use on a daily basis, there's nothing wrong with learning some handy Unix commands. The commands covered in this section will help you on the day-to-day tasks of quickly testing, parsing, and searching through your text data.

If you're a Windows user, you can still join in by downloading Cygwin, which is a Unix shell command interpreter. Cygwin is a shell that sits on top of the Windows Command application and behaves like it's a Unix install.

Some of these commands will appear from time to time in the chapters of this book, so it's worth reviewing them now. Experiment with them and study the output so you have an idea of what to expect.

Using Sample Data

Before you get started with the tools, you need some sample data. With a text editor, type out the following lines and separate each value with a tab:

987  1391548780  hhh bbb
988  1391548781  sda jjj
989  1391548782  asd asd
990  1391548783  gjh jkl
991  1391548784  abc abc
992  1391548785  ghj gjh
993  1391548785  hhh bbb
994  1391548785  sda jjj
995  1391548786  asd asd
996  1391548787  gjh jkl
997  1391548787  abc abc
998  1391548787  ghj gjh

Name the text file text.txt, and then you can follow along with the following commands and see the output. The sample data is basically comprised of a unique ID, a timestamp, and some text. It's the sort of thing you would see within a database table but is output as text. This example uses a tab delimiter, but you might find data with ...

Get Machine Learning, 2nd Edition 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.