Implement "head", "head-n", "tail", "tail-n" commands.