In my bat script, what do I use to open a file called open.txt and add the following line to the top
SOME TEXT TO BE ADDED
Can small edits like this be handled in a .bat script
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure, with something like:
The first line makes a temporary copy of the file. The second line overwrites the file with the line you want to add (note particularly the lack of spaces between the text being added and the
>redirection operator –echohas a nasty habit of including such spaces).The third line uses the append redirection operator
>>to add the original file to the end of the new one, then the final line deletes the temporary file.