doskey

Setup windows doskey for echo > filename.txt


My goal is to setup doskey to imitate unix touch command as touch filename.txt

Without doskey I use echo . > filename.txt in the windows's command prompt

I successfully setup doskey touch=echo $* but I must use it as touch > filename.txt, I have tried to play around using doskey touch=echo > $*, this causes echo to be not recognized by the windows's command prompt.

Please help, thanks.

Please help,


Solution

  • Try this

    doskey touch=copy nul $* > nul
    

    This bit of code exploits the copy command to make a new file. $* is the string you put after touch.