lundi 12 mars 2018

sed paste below pattern string in variable

I am looking for a solution to paste a variable below a matching pattern I have a half solution but cannot finish my script... My aim with this script is to paste the variable "OSI" automatically below the correct Month.

kind regards Goeks

/var/etc/osi.conf

###Jan###
###Feb###
###Mar###
###Apr###
###May###
###Jun###
###Jul###
###Aug###
###Sep###
###Oct###
###Nov###
###Dec###

Script:

#!/bin/bash +x
DATE=$(date | awk '{print $2}')
DATE2=$(date +%Y-%m-%d -d "3 year")
read -r -p "USERNAME: " USERNAME
read -r -p "PASSWORD: " PASSWORD


OSI="
"$USERNAME"
"$PASSWORD"
"$DATE2"
Fail 1
eth0"

sed -i 's/\#\#\#"$(date | awk '{print $2}')"\#\#\#/$OSI/g' /var/etc/osi.conf

Aucun commentaire:

Enregistrer un commentaire