Note- Petri's link is currently down. He got it from windows server 2003 but I see clip.exe on windows 7 too. It's on windows versions post windows 7 too.
C:\>echo abc| clip <-- copies abc to the clipboard.
The main thing is that clip command but as pointed out by Asu, a line like
echo abc will also send a \r\n (which is a new line). If you want to avoid that, then that's a very standard issue solved by replacing
echo texttoecho, with
You can of course then paste with right click, but for a command line paste too.
unxutils(an ancient thing not maintained since the 1990s) has gclip and pclip (they don't seem to be in gnuwin32), with those you can copy and paste via command line.
note- gnuwin32 might not be that updated either. Gnuwin32 was last updated in 2010! Cygwin is still updated but anyhow.
C:\unxutilsblah\usr\local\wbin>echo a|gclip <-- copy a to clipboard
note- you can just copy all of wbin to e.g.
c:\unxutils, and the EXEs have no dependencies/dlls.
and you can of course do pclip>a.a to paste to a file. or pclip|somecmd
C:\>(echo b & echo a)<ENTER>
C:\unxutils>(echo b & echo a)|gclip<ENTER>