This question already has an answer here:
- Line numbering - implement nl 8 answers
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)
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<>