0

I want to display a text file in my command prompt using batch file such that, if the content of my text file is as follows

Hi there!

My name is Pranay.

I want to try giving numbers to the lines in my text file.

The output in my command prompt (but not in my text file) should be as follows:

1) Hi there!

2) My name is Pranay

3) I want to try giving numbers to the lines in my text file.

Pls do help.

13
  • 2
    Welcome to Super User! Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?. – DavidPostill Aug 1 '16 at 18:11
  • This is not a difficult problem, but we expect users to make some effort to solve things themselves before asking us to give up our free (and unpaid) time to write customised scripts. – DavidPostill Aug 1 '16 at 18:12
  • In my college, for my course in UNIX programming I have learnt that we can achieve it in UNIX by command named "nl" hence I tried that command in my windows command prompt using " nl hello.txt ". But the prompt said no nl command found. – Pranay Raju Aug 1 '16 at 18:44
  • 1
    You could start with findstr /N "^" yourfile, see ss64.com/nt/findstr.html – JosefZ Aug 1 '16 at 18:46
  • 1
    for /f "tokens=1* delims=:" %G in ('findstr /N "^" file.ext) do @echo %G^) %H if @DavidPostill expects full answer… I gave only a starting point… – JosefZ Aug 1 '16 at 18:53

Your Answer

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

Browse other questions tagged or ask your own question.