-1

I am trying to make a file with the command line with the form of

mkdir -p /path/to/directory && touch /path/to/directory/file.txt

so in my case it will be like this: mkdir -p layout && touch layout/layout.ejs, but I receive a message

touch is not recognized as an internal or external command, operable program or batch file.

The folder has been made successfully but the file is not.

phuclv
  • 27,773

1 Answers1

1

Not sure what you're trying to do. You can send text in CMD to a file using the redirect command, >. E.G.

echo "hello world" >c:\temp\layout.ejs

Sends this:

"hello world"

to the file layout.ejs in the C:\temp folder.

Giacomo1968
  • 55,001
DrMoishe Pippik
  • 29,631
  • 5
  • 41
  • 58
  • Thank's but this didnot solve the problem also,As I need one command line to make adirectory and a file in the same timing – mohamed elnashar Dec 18 '23 at 01:24
  • two steps: c:\temp\glorp and echo "hello world" >c:\temp\glorp\layout.ejs. Use & or && to do it on one line. https://stackoverflow.com/questions/8055371/how-do-i-run-two-commands-in-one-line-in-windows-cmd Read a tutorial, e.g., https://www.freecodecamp.org/news/command-line-commands-cli-tutorial/ – DrMoishe Pippik Dec 18 '23 at 02:09
  • I do want to make an empty file for now and I try your answer the system cannot find the folder specified and try to add dir in the first got the the system cannot find the file specified can you show me the command which already working with you – mohamed elnashar Dec 18 '23 at 03:53