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

Author Topic: how to echo line both on screen and text file  (Read 3618 times)

0 Members and 1 Guest are viewing this topic.

srujana

  • Guest
how to echo line both on screen and text file
« on: November 29, 2011, 09:15:26 AM »
I want to display the output both on screen and log.txt file

like

echo %%a > log.txt

this is redirecting to txt file. i want on screen as well

is ther any way?

Raven19528



    Hopeful
  • Thanked: 30
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: how to echo line both on screen and text file
    « Reply #1 on: November 29, 2011, 09:25:42 AM »
    The only way I know of is to echo the line twice.

    Code: [Select]
    echo %%A > log.txt
    echo %%A

    I know it is an extra line, but is there any reason this won't work?
    "All things that are
    Are with more spirit chased than enjoy'd" -Shakespeare

    Squashman



      Specialist
    • Thanked: 119
    • Experience: Experienced
    • OS: Other
    Re: how to echo line both on screen and text file
    « Reply #2 on: November 29, 2011, 05:59:52 PM »
    Unlike most Nix systems there is not a native way to do this in batch.  You can use the TEE command on most NIX operating systems to do this.  I believe there is a Win32 port of it if you really want to do this.

    Salmon Trout



      Genius

      Thanked: 920
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Other
    Re: how to echo line both on screen and text file
    « Reply #3 on: November 30, 2011, 11:32:12 AM »
    Unlike most Nix systems there is not a native way to do this in batch.  You can use the TEE command on most NIX operating systems to do this.  I believe there is a Win32 port of it if you really want to do this.

    There are plenty of Tee.exe programs around, not to mention any number of Tee.bat. Tee.cmd and Tee.vbs scripts. The most cursory of Google searches will turn up plenty of results, which it would be both tedious and redundant to reproduce here. In particular searching the Google archive of alt.msdos.batch.nt using intelligently chosen search terms is a fruitful method of finding solutions.

    If the OP is using a business or school system where installation of third party executables is not allowed, then a cmd or vbs approach may be the only way.



    _her0brin3



      Newbie

      • Experience: Experienced
      • OS: Windows 8
      Re: how to echo line both on screen and text file
      « Reply #4 on: December 16, 2013, 09:54:18 AM »
      You can use:

      echo %%a >> log.txt
      echo %%a

      in one line, maybe use a pipe, fork, or do:

      echo %%a >> log.txt && echo %%a

      Thats your best option