$ perl -e'my $i=0; while (<>) { print ++$i, " $_" }' file 1 foo 2 bar 3 baz 4 qux