Find Number of fields in a file

To find the number of fields in a TSV file just do the following:

First calculate the number of tabs:

$ head -1 /tmp/file.txt |  egrep -o -E $'\t' | wc -l

The number of fields is number of tabs separating the fields + 1

16 + 1 = 17


Now read this

Hive and Hadoop Command Snippet search

Why? # I’ve found myself looking up the “exact” syntax for DML / DDL in Hive countless times. Also, I tend to forget the list of date functions and parameters. I would use a combination of Google Search and/or a cheat sheet for these.... Continue →