2 edited tags
| link
1
source | link

sed: insert text after specific character in a specific line

Below is my text file:

example.txt
INTERFACESv4=""
INTERFACESv6=""

Below is my code (it inserts an IP address after the 14th character):

ip_add="192.168.1.2"
file_name="$HOME\Documents\example.txt"
sed -i "s/^\(.\{14\}\)/\1${ip_add4}/" "$file_name"

Below is the output of my text file:

example.txt
INTERFACESv4="192.168.1.2"
INTERFACESv6="192.168.1.2"

How do I insert the text in just the first line?