Is there a Unix command to prepend some string data to a text file?
Something like:
prepend "to be prepended" text.txt
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.
-iwrites the change in place and take a backup if any extension is given. (In this case,.old)1s;^;to be prepended;substitutes the beginning of the first line by the given replacement string.1means act on the first line,smeans replace,;is the delimiter we’ve selected fors(/is a common choice as ins///but any character can be used) and^is the regular expression that matches the beginning of a lineIf you want to add a new line to the beginning of the file, you need to add
\non the replacement as in: