Loading ...
Sorry, an error occurred while loading the content.

"echo -n" equivalent in batch files

Expand Messages
  • Parag P. Doke
    Hello All. Wishing everyone a very happy new year. I have a tiny question. Is there a method in batch files to echo something without the newline ? [equivalent
    Message 1 of 5 , Jan 2, 2008
    • 0 Attachment
      Hello All.
      Wishing everyone a very happy new year.
      I have a tiny question. Is there a method in batch files to echo
      something without the newline ? [equivalent of "echo -n" in Unixes].

      I have a fixed string (say "batchworld") that has to be added before
      the ouput of a command. Normally, I could have used:
      for /f "delims=" %%i in ('myCommand') do echo batchworld%%i >> myFile.txt
      However, "myCommand" uses java to read a few property files and the
      output goes beyond the character limit of cmd.

      It is not that searching for "echo -n" might be the best method to
      achieve this. If anyone has a better option (preferably without 3rd
      party utilities), I'm open for suggestions. I shall be using this on
      Win2K, WinXP and sometimes Win2K3.

      Thank you in advance.
      --
      Parag P. Doke
      http://paragpdoke.blogspot.com
    • foxidrive
      On Wed, 2 Jan 2008 17:28:04 +0530, Parag P. Doke ... XP has a command line limit of 8KB but W2k is a paltry 2KB. An example of what
      Message 2 of 5 , Jan 2, 2008
      • 0 Attachment
        On Wed, 2 Jan 2008 17:28:04 +0530, "Parag P. Doke" <paragpdoke@...>
        wrote:

        >I have a tiny question. Is there a method in batch files to echo
        >something without the newline ? [equivalent of "echo -n" in Unixes].
        >
        >I have a fixed string (say "batchworld") that has to be added before
        >the ouput of a command. Normally, I could have used:
        >for /f "delims=" %%i in ('myCommand') do echo batchworld%%i >> myFile.txt
        >However, "myCommand" uses java to read a few property files and the
        >output goes beyond the character limit of cmd.

        XP has a command line limit of 8KB but W2k is a 'paltry' 2KB.

        An example of what you're attempting to join would be useful, or the error that
        your command above generates.

        >It is not that searching for "echo -n" might be the best method to
        >achieve this. If anyone has a better option (preferably without 3rd
        >party utilities), I'm open for suggestions. I shall be using this on
        >Win2K, WinXP and sometimes Win2K3.
      • Parag P. Doke
        Hi Mic. Ummm.....I m not sure if pasting the command or its output would be the right thing to do....so let me share a fake one instead. ... C: for /f
        Message 3 of 5 , Jan 2, 2008
        • 0 Attachment
          Hi Mic.
          Ummm.....I'm not sure if pasting the command or its output would be
          the right thing to do....so let me share a fake one instead.
          >>>>>
          C:\>for /f "delims=" %i in ('type c:\abc.txt') do echo batchworld%i

          C:\>
          <<<<<
          This is on Win2K profession SP4. "C:\abc.txt" is a file with any text.
          In my case, I created a random one with a single line of text and is
          10.9 KB large. [Had not known about the different limits in XP and 2k.
          Thanks for sharing them.] I have uploaded my file here:
          http://paragpdoke.googlepages.com/abc.txt

          Btw....While I was composing this reply, I noticed that this being the
          only odd part in the file I intend to create (say myFile.txt as in my
          last mail), it will be possible for me to pre-pend some fixed text to
          other lines...and skip it for this one. While parsing this file, I
          will skip the line without the prefix and get hold of the text. So it
          is not really a blocking issue anymore.


          Thanks,
          Parag P. Doke
          On Jan 2, 2008 5:43 PM, foxidrive <foxidrive@...> wrote:
          >
          >
          >
          >
          >
          >
          > On Wed, 2 Jan 2008 17:28:04 +0530, "Parag P. Doke" <paragpdoke@...>
          > wrote:
          >
          > >I have a tiny question. Is there a method in batch files to echo
          > >something without the newline ? [equivalent of "echo -n" in Unixes].
          > >
          > >I have a fixed string (say "batchworld") that has to be added before
          > >the ouput of a command. Normally, I could have used:
          > >for /f "delims=" %%i in ('myCommand') do echo batchworld%%i >> myFile.txt
          > >However, "myCommand" uses java to read a few property files and the
          > >output goes beyond the character limit of cmd.
          >
          > XP has a command line limit of 8KB but W2k is a 'paltry' 2KB.
          >
          > An example of what you're attempting to join would be useful, or the error
          > that
          > your command above generates.
          >
          >
          > >It is not that searching for "echo -n" might be the best method to
          > >achieve this. If anyone has a better option (preferably without 3rd
          > >party utilities), I'm open for suggestions. I shall be using this on
          > >Win2K, WinXP and sometimes Win2K3.
          >
          >



          --
          Parag P. Doke
          http://paragpdoke.blogspot.com
        • Garry Deane
          ... I m not really sure what you re trying to achieve but the following will produce the equivalent of echo -n set /p dummyvar=Test string
          Message 4 of 5 , Jan 2, 2008
          • 0 Attachment
            --- In batchworld@yahoogroups.com, "Parag P. Doke" <paragpdoke@...>
            wrote:
            >
            > Hi Mic.
            > Ummm.....I'm not sure if pasting the command or its output
            > would be the right thing to do....so let me share a fake one
            > instead.
            > >>>>>
            > C:\>for /f "delims=" %i in ('type c:\abc.txt') do echo batchworld%i
            >
            > C:\>
            > <<<<<
            > This is on Win2K profession SP4. "C:\abc.txt" is a file with
            > any text. In my case, I created a random one with a single line
            > of text and is 10.9 KB large. [Had not known about the different
            > limits in XP and 2k. Thanks for sharing them.] I have uploaded
            > my file here: http://paragpdoke.googlepages.com/abc.txt
            >
            > Btw....While I was composing this reply, I noticed that this
            > being the only odd part in the file I intend to create (say
            > myFile.txt as in my last mail), it will be possible for me
            > to pre-pend some fixed text to other lines...and skip it for
            > this one. While parsing this file, I will skip the line without
            > the prefix and get hold of the text. So it is not really a
            > blocking issue anymore.
            >
            >
            > Thanks,
            > Parag P. Doke

            I'm not really sure what you're trying to achieve but the
            following will produce the equivalent of echo -n

            set /p "dummyvar=Test string " <nul

            Garry
          • Parag P. Doke
            Hello Garry. Yes ! It works for me. I wanted to add a word (or redirect to be precise) to a file. Then on the same line, add output of another command. I tried
            Message 5 of 5 , Jan 3, 2008
            • 0 Attachment
              Hello Garry.
              Yes ! It works for me. I wanted to add a word (or redirect to be
              precise) to a file.
              Then on the same line, add output of another command. I tried this:
              set /p dummyvar=batchworld < nul > myFile.txt
              myCustomCommand >> myFile.txt

              Thank you for sharing this.

              Best regards,
              Parag P. Doke

              On Jan 3, 2008 6:46 AM, Garry Deane <garrydeane@...> wrote:
              >
              >
              >
              >
              >
              >
              > --- In batchworld@yahoogroups.com, "Parag P. Doke" <paragpdoke@...>
              >
              > wrote:
              > >
              > > Hi Mic.
              > > Ummm.....I'm not sure if pasting the command or its output
              > > would be the right thing to do....so let me share a fake one
              > > instead.
              > > >>>>>
              > > C:\>for /f "delims=" %i in ('type c:\abc.txt') do echo batchworld%i
              > >
              > > C:\>
              > > <<<<<
              > > This is on Win2K profession SP4. "C:\abc.txt" is a file with
              > > any text. In my case, I created a random one with a single line
              > > of text and is 10.9 KB large. [Had not known about the different
              > > limits in XP and 2k. Thanks for sharing them.] I have uploaded
              > > my file here: http://paragpdoke.googlepages.com/abc.txt
              > >
              > > Btw....While I was composing this reply, I noticed that this
              > > being the only odd part in the file I intend to create (say
              > > myFile.txt as in my last mail), it will be possible for me
              > > to pre-pend some fixed text to other lines...and skip it for
              > > this one. While parsing this file, I will skip the line without
              > > the prefix and get hold of the text. So it is not really a
              > > blocking issue anymore.
              > >
              > >
              > > Thanks,
              > > Parag P. Doke
              >
              > I'm not really sure what you're trying to achieve but the
              > following will produce the equivalent of echo -n
              >
              > set /p "dummyvar=Test string " <nul
              >
              > Garry
              >
              >



              --
              Parag P. Doke
              http://paragpdoke.blogspot.com
            Your message has been successfully submitted and would be delivered to recipients shortly.