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

Configuring DHCP Relay service on the FortiGate unit

WAN link load balancing