You must do a program that reads a file given in first argument and print it's content to STDOUT and number the lines on the file, the numbers should be followed by a space.
For instance, assuming that your program is named cat, we could write ./cat "myfile.txt" (or execute it with its interpreter)

With myfile.txt:

Hello, world, this
is a file with
multiple characters..0

And the program should output to STDOUT :

1  Hello, world, this
2  is a file with
3  multiple characters..0

The shortest program in bytes win.

For example :


$r++&print"$r ".$_ while<>
  • \$\begingroup\$ Well, this one is a bit simpler than the Line numbering - implement nl. On this last one, there are restrictions on the length of the file and the program must return error codes. What I want to do here is the smallest program in many languages for just a simple thinks, no matter the length of the file and with only one file at a time. \$\endgroup\$ – tourdetour Dec 22 '15 at 18:38

LabVIEW, 32 LabVIEW Primitives

Reads line by line and concatenates numbers space and newlines, then deletes a trailing number, space and newline.


Not the answer you're looking for? Browse other questions tagged or ask your own question.