How to insert data to the first line of a file in bash

To insert data to the first line of a file in bash, we can use sed utility.

#sed -i '1i data' file

where,

data - data to be inserted

file - name of the file to be processed

Leave a Reply

Your email address will not be published. Required fields are marked *