Insert/Add String to Beginning of a File

Inserting a String to Beginning of File

  1. Suppose you had a text file with the contents and you wanted to insert a string to the beginning:
    1st line
    2nd line
    3rd line
  2. Run the command:
    sed -i '1s/^/<add text > \n/' file.txt
  3. Now the file will look like this:
    Top of the file!
    1st line
    2nd line
    3rd line

Nhận xét

Bài đăng phổ biến từ blog này

CLEANING UP THE ZABBIX DATABASE

[Resolved] Amazon EC2 Redhat 7 using 6GB for the root space

Connect to a different port with SQL Server Management Studio