I want to view lines 2-5 of a text file I created by merging. all i can find is either head or tail commands but i need to view this specific set of lines with command.
I want to view lines 2-5 of a text file I created by merging. all i can find is either head or tail commands but i need to view this specific set of lines with command.
HDFS files are split into blocks. Not all files are "line delimited", so therefore this is not a common operation that's exposed by any HDFS tool.
You'll need to write your own program to do this, such as MapReduce, Hive, Pig or Spark (somehow add line number as a field/column, then simply select/filter by a range query).
But you could also use the hdfs head command given your end offset (5), then pipe into the Unix tail command with the difference plus 1 (5-2 + 1 = 4), and get the "last 4 lines of the head", or lines 2-5 (inclusive)