Jonathan Viju Mathai
Jonathan Viju Mathai

Reputation: 437

How to have a batch file create another batch file

I'm want to make my main batch file create another batch file. my main one is in a flash drive, i want it to make another batch file to eject it having it eject the main is easy, my problem is having the main create a brand new batch and dictate which commands go in it

Upvotes: 0

Views: 2104

Answers (2)

quant
quant

Reputation: 2224

If you need multiple lines, you can use:

cat > newBashFile.sh << EOF
echo "first line"
echo "second line"
# multiple more commands, as long as they don't contain the string EOF
EOF

Another solution would be:

echo -e "first command\nsecond command\n..." > bashFile.sh

Upvotes: 1

derogab
derogab

Reputation: 152

Try this:

echo. content > newfile.bat

Upvotes: 0

Related Questions