How do I, in a shell script, create a file called foo.conf and make it contain:
NameVirtualHost 127.0.0.1 # Default <VirtualHost 127.0.0.1> ServerName localhost DocumentRoot "C:/wamp/www" </VirtualHost>
To create a new file, run the "cat" command and then use the redirection operator ">" followed by the name of the file. Now you will be prompted to insert data into this newly created file. Type a line and then press "Ctrl+D" to save the file.
To create a new file run the cat command followed by the redirection operator > and the name of the file you want to create. Press Enter type the text and once you are done press the CRTL+D to save the files.
You can do that with echo
:
echo 'NameVirtualHost 127.0.0.1 # Default <VirtualHost 127.0.0.1> ServerName localhost DocumentRoot "C:/wamp/www" </VirtualHost>' > foo.conf
Everything enclosed by single quotes are interpreted as literals, so you just write that block into a file called foo.conf
. If it doesn't exist, it will be created. If it does exist, it will be overwritten.
Use a "here document":
cat > foo.conf << EOF NameVirtualHost 127.0.0.1 # Default <VirtualHost 127.0.0.1> ServerName localhost DocumentRoot "C:/wamp/www" </VirtualHost> EOF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With