- Forums
- Linux
- How To Add Text At Beginning Of File Linux Command
this post will show you how to add text at beginning of file linux command using the linux shell command using sed you can insert and put one more line at the top of the file using whatever text you want to use [3305], Last Updated: Mon Jun 24, 2024
Webune Support
Sat Mar 13, 2010
3 Comments
469 Visits
this post will show you how to add text at beginning of file linux command using the linux shell command using sed you can insert and put one more line at the top of the file using whatever text you want to use
for example, i want to put on the first line a comment in my .htaccess file in my webs directory located at /var/webune/support/.htaccess
'sed -i.bak '1i #These are Webune Comments ' /var/webune/support/.htaccess
this code will create a backup copy called .htaccess.bak and also add
#These are Webune Comments to the first line
hope that help and this is what you were looking for
this was tested in a Fedora,Redhat, CentOS machine