4

How do I open a file in more mode with line numbers. I am using ksh on AIX

for less I use -N but for more it is not working.

less -N filename

2

For a 100% portable approach, you can use awk:

awk '{print NR,$0}' file | more
  • Thank you so much. It is working. How do I go to end of file in this mode. – Aravind Sep 17 '15 at 12:15
  • @Aravind huh? Just like you would with any other stream opened in more. Hit space repeatedly. Or, just pick up the last few lines: awk '{print NR,$0}' file | tail -n 50 | more. – terdon Sep 17 '15 at 12:19
2

You can use the nl tool which may also be available for AIX (e.g. part of GNU coreutils):

nl filename | more
0

FWIW, if you are familiar with vi you can also use that. To enable display of line numbers (in case it is not in your ~/.exrc) simply enable it in command mode via :set numbers or the shorter form :se nu.

  • file size is more, i can't open in vi editor. – Aravind Sep 24 '15 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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