1

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,

Artisan
  • 4,042
  • 13
  • 37
  • 61
  • I am trying to to the same. I will let you know if I have any success. I was trying with touch=type NUL > $* – Marcel Mar 10 '15 at 20:09

1 Answers1

3

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.

Marcel
  • 1,034
  • 1
  • 17
  • 35
  • Generally, answers are much more helpful if they include an explanation of what the code is intended to do, and why that solves the problem without introducing others. – Jaime Gómez Mar 11 '15 at 08:10
  • " copy nul $* " is enough. I use " type nul > filename " for touch ,but "type nul > $*" does not work. Do you know why? – ws_ Feb 16 '20 at 15:18