How to copy command line text to a file?

Vishal Sharma

Vishal Sharma

@vishal-pysGmK Oct 15, 2024
how to store the contents on command prompt on to a file?? Is there any buffer log created? like we have in SQL? (the 'ed' command opens up the latest entry)
does anyone know about it??

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Aug 8, 2013

    You haven't mentioned whether you want the copy the contents manually or use commands to do so. Copying manually is easy. Assuming that you're in Windows environment, you'll have to right-click on the command prompt Window and select 'Mark'. Then select the text you want to copy and then Rt.Click -> Copy.

    I think you already know this. Please clarify your requirements.
  • Nayan Goenka

    Nayan Goenka

    @nayan-Dhpt4N Aug 8, 2013

    After any command you execute, add this ">filename.txt". this will add the output of your command into thisfile. For ex:

    tracert <a href="https://www.crazyengineers.com">CrazyEngineers</a> > trace.txt

    This command will make a file trace.txt in your current working directory and copy all the output there instead of showing it on the screen.
  • Vishal Sharma

    Vishal Sharma

    @vishal-pysGmK Aug 8, 2013

    I'm not being answered to what I've asked
    Leaving the manual stuff behind, I want to go for a programmatic way.

    After any command you execute, add this ">filename.txt". this will add the output of your command into thisfile. For ex:

    tracert <a href="https://www.crazyengineers.com">CrazyEngineers</a> > trace.txt

    This command will make a file trace.txt in your current working directory and copy all the output there instead of showing it on the screen.​
    yes, this works.. It is called re-directing and it works only with commands.. my question is not this. If something is already being displayed, that content should be moved to a text file. I think in linux we have script command to perform this kind of operation.. what about windows?
  • rukawa

    rukawa

    @rukawa-Y0pUkC Aug 8, 2013

    Vishal0203
    I think in linux we have script command to perform this kind of operation.. what about windows?

    What's the way to do this kind of operation in linux?
  • Vishal Sharma

    Vishal Sharma

    @vishal-pysGmK Aug 9, 2013

    rukawa
    What's the way to do this kind of operation in linux?

    Script i think.. never used linux though.. got this suggestion from someone
  • sookie

    sookie

    @sookie-T06sFW Aug 27, 2013

    Have you tried doskey /history >> commands.log ?
  • KenJackson

    KenJackson

    @kenjackson-mBf7HF Aug 27, 2013

    Vishal0203
    I think in linux we have script command to perform this kind of operation.. what about windows?
    Most things that you can do in Linux, including <a href="https://en.wikipedia.org/wiki/Script_(Unix)" target="_blank" rel="nofollow noopener noreferrer">Script (Unix)</a>, you can do in the <a href="https://cygwin.com/" target="_blank" rel="nofollow noopener noreferrer">Cygwin</a> environment in Windows. That is, download setup-x86.exe or setup-x86_64.exe from Cygwin and execute it to install a Linux-like tools for Windows. I couldn't use Windows without it.