Sorry if this has been discussed, wasn't sure what to use to search for the particular question I had.

I'm installing sickrage and couchpotato and headphones, and will be doing multiple installs I made a small batch script just to install everything but what I don't know how to do is automatically make them auto start on boot. Since they all require a file to be created I do not know how to make this file auto create and populate what needs to be put into it.

  • 1
    In bash scripting touch will create a new file and >> will append to the end of a file. Ex. touch newfile && echo This is a test >> newfile – karel Aug 23 '14 at 19:56
  • Can you give an example of what needs to be populated? If it's anything more than a couple of lines, I'd use a here document. – steeldriver Aug 23 '14 at 19:59
  • Would you mind sharing your bash script? – user319848 Aug 23 '14 at 21:53

As Karel suggested you can use touch to create the file and other commands to populate it:

Now Assuming you have created a file as follows: touch path/to/file we can use the following methods to populate it:

printf "Hello world\nNow a new line" >> path/to/file


echo "Hello world\nNow a new line " >> path/to/file

you can use >> to append to the file or > to replace everything in the file with new content.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.