Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How many lines  (Read 9493 times)

0 Members and 1 Guest are viewing this topic.

ghostdog74



    Specialist

    Thanked: 27
    Re: How many lines
    « Reply #15 on: March 14, 2009, 04:04:14 AM »
    install Gawk for windows, then on the command line
    Code: [Select]
    c:\> gawk 'END{print NR}' file
    17

    if you want to do programming/batching on windows, get a real programming language.

    Reno



      Hopeful
    • Thanked: 32
      Re: How many lines
      « Reply #16 on: March 14, 2009, 04:21:19 AM »
      why install third party solution when you can do this in almost any windows-based PC without installing anything.
      NT cmd.exe is a powerful interpreter for text based manipulation.

      No need to install anything, then on the command line
      Code: [Select]
      C:\>type config.sys|find/c /v ""
      2

      ghostdog74



        Specialist

        Thanked: 27
        Re: How many lines
        « Reply #17 on: March 14, 2009, 09:03:38 AM »
        why install third party solution when you can do this in almost any windows-based PC without installing anything.
        We don't live in prehistoric times. Given computing technology today, why is one restricted to what you have. If a tool can reduce hours of coding and increase productivity to the business, its best to use them all to our advantage. A computer is bought just to do that. Increase productivity. Your Windows goes out to the internet for auto updates. That's also installing, isn't it?. What's the difference.

        Quote
        NT cmd.exe is a powerful interpreter for text based manipulation.

        No need to install anything, then on the command line
        Code: [Select]
        C:\>type config.sys|find/c /v ""
        2
        yes, its powerful, but not powerful enough. It can only do this much, anything more complex, it becomes ugly. try parsing a file and doing complex string manipulations EASILY using cmd.exe (and *.exe in system32). Try doing automated telnetting with proper error control. try grabbing a web page and getting some information out of it. Doing them in batch? no way.

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: How many lines
        « Reply #18 on: March 14, 2009, 09:10:30 AM »
        install Gawk for windows, then on the command line
        Code: [Select]
        c:\> gawk 'END{print NR}' file
        17

        if you want to do programming/batching on windows, get a real programming language.

        indeed, I always find it much more convenient to write a vbscript like this:

        Code: [Select]
        set fso = createobject("scripting.filesystemobject")
        set fstream = fso.getfile(wsh.arguments(1)).OpenAsTextStream
        wsh.echo fstream.readall
        fstream.close

        instead of the ridiculously difficult to understand:

        Code: [Select]
        type filename

        Oh wait- NO I DON'T!


        if you've seen some threads were I provide a VBScript solution and Dias provides a batch solution- oddly the batch solution is shorter.

        And if you would like to contest wether VBScript is a programming language you might want to take that up with Eric Lieppert.
        I was trying to dereference Null Pointers before it was cool.

        ghostdog74



          Specialist

          Thanked: 27
          Re: How many lines
          « Reply #19 on: March 14, 2009, 09:48:55 AM »

          if you've seen some threads were I provide a VBScript solution and Dias provides a batch solution- oddly the batch solution is shorter.

          And if you would like to contest wether VBScript is a programming language you might want to take that up with Eric Lieppert.
          you are going OT.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: How many lines
          « Reply #20 on: March 14, 2009, 12:07:02 PM »
          We don't live in prehistoric times. Given computing technology today, why is one restricted to what you have. If a tool can reduce hours of coding and increase productivity to the business, its best to use them all to our advantage. A computer is bought just to do that. Increase productivity. Your Windows goes out to the internet for auto updates. That's also installing, isn't it?. What's the difference.
          yes, its powerful, but not powerful enough. It can only do this much, anything more complex, it becomes ugly. try parsing a file and doing complex string manipulations EASILY using cmd.exe (and *.exe in system32). Try doing automated telnetting with proper error control. try grabbing a web page and getting some information out of it. Doing them in batch? no way.

          And I'm the one going off-topic? Don't see much about counting the lines in a file there, mostly just a shameless plug for your ridiculous and unnecessary, if not useful, command-line tool of choice. (And no, unnecessary and useful are not mutually exclusive)

          Which brings up the fact that windows updates- automatically,, as in, without requiring the user to search for an install a third party tool.

          This is Reno's Point- you can make a third party tool as powerful as you want- but if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?

          your proposed problems are merely invented scenarios devised for the sole purpose of being difficult- if not impossible- via CMD line batch processing commands; except perhaps the first one- since cscript.exe can be used to perform easy string manip via Jscript or VBScript code from batch; and in fact that goes for most of the other proposed "problems".

          The funniest part is me and Dias are discussing various ways of performing this task with various levels of compatibility for different newline methods with tools provided in default OS installs and you jump in with a suggestion to install some third party tool and provide some code for it that accomplishes nothing more then that which Dias had already provided, except perhaps clutter up their PC with more software installations.

          Hubris.
          I was trying to dereference Null Pointers before it was cool.

          Dias de verano

          • Guest
          Re: How many lines
          « Reply #21 on: March 14, 2009, 12:46:10 PM »
          Although I quite like fooling around with awk, sed, perl, Ruby etc -- I am getting into Python at the moment -- also the Resource Kits can be useful -- I don't tend to push these others on people here because as you say, BC_Programmer, "if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?". Especially if people are prevented from installing 3rd party apps. In fact I get a kind of perverse pleasure in seeing what can be done with the default tools.

          ghostdog74



            Specialist

            Thanked: 27
            Re: How many lines
            « Reply #22 on: March 14, 2009, 01:41:24 PM »
            And I'm the one going off-topic? Don't see much about counting the lines in a file there, mostly just a shameless plug for your ridiculous and unnecessary, if not useful, command-line tool of choice. (And no, unnecessary and useful are not mutually exclusive)
            please read the quote where the reply is directed. A question was asked on "why install a third party ....". I gave the reasons why, mostly for productivity. So where did i go OT? Whereas for your case, since when did i say Vbscript is not a programming language and why should i contest the guy you mentioned? Isn't it going OT ? get your facts right.

            Quote
            Which brings up the fact that windows updates- automatically,, as in, without requiring the user to search for an install a third party tool.
            is searching for a third party tool that difficult?

            Quote
            This is Reno's Point- you can make a third party tool as powerful as you want- but if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?
            like i said, productivity. Even in the case of programming tools/languages. If you want to send email in your script, do you write a whole bunch of vbscript code or do you prefer to use things like blat ? That is just an example but if you have ever been a system administrator (or equivalent) that need to perform complex tasks like FTP, telnet to remote and execute jobs etc you will know that you definitely need better tools or Libraries to do your work than using merely cmd.exe

            Quote
            your proposed problems are merely invented scenarios devised for the sole purpose of being difficult- if not impossible- via CMD line batch processing commands; except perhaps the first one- since cscript.exe can be used to perform easy string manip via Jscript or VBScript code from batch; and in fact that goes for most of the other proposed "problems".
            please read my post again. I said "...doing complex string manipulations EASILY...".  (sidenote: do you want to have a shot at solving those problems i mentioned using just vbscript.? )

            Quote
            The funniest part is me and Dias are discussing various ways of performing this task with various levels of compatibility for different newline methods with tools provided in default OS installs and you jump in with a suggestion to install some third party tool and provide some code for it that accomplishes nothing more then that which Dias had already provided, except perhaps clutter up their PC with more software installations.
            It's funny because I was replying to the OP and giving an alternative suggestion (and its cross platform). Why should i be bothered about your discussion with Dias since OP didn't even mentioned he can't install 3rd party tools, or whatever you call it.
            and wait, so you mean to say i cannot post my suggestions in this forum? I mean, my posts are  not meant for you , you know? If my suggestion does not suit the OP, its fine. He has the final say and I am a willing contributor. Its NOT up to you to say anything. Cluttering up the PC? what are you talking about? you mean to say, things like automatic updates which MS downloads from the internet is not cluttering up the PC?? so you mean to say useful tools from the resource kits cannot be used etc?
            « Last Edit: March 14, 2009, 01:56:02 PM by ghostdog74 »

            ghostdog74



              Specialist

              Thanked: 27
              Re: How many lines
              « Reply #23 on: March 14, 2009, 02:00:06 PM »
              , "if it can be done in something that is included in the default install, whats the point of using a separate tool, third party or otherwise?".
              if i were to say "its for improving workplace productivity", would you accept that as a reasonable answer.