I'm expecting this to be an easy one for someone (alas not me!).

Using a bash script, I want to replace a value in a config file '/etc/app/app.cfg' (ini style), using variables for both search and replace.

The Value Name and Value I wish to update (note the space either side of the equals:

`LOGDIR = /etc/app/logs`

I have defined the following in the bash script:

```
# Get existing LogDir value 
CURRENT_LOGDIR=$(grep 'LogDir =' /pathtofile | sed 's/LogDir *= *//g')

# Set New LogDir
LOGDIR=/mnt/eft/fs1/logs

# Update LogDir if different
if [[ -d $(echo $CURRENT_LOGDIR) != $LOGDIR ]] ; then
  # Update LogDir value:
  **bash command - I need help with !**
fi

```

I have tried many combinations with sed, to no avail, hence asking this question.

Things I've tried:

```
echo "LogDir = $LOGDIR" | sed '#s/$CURRENT_DIR/$LOGDIR/#g' /etc/app/app.cfg
sed -i '/#/!s/\(LogDir[[:space:]]*=[[:space:]]*\)\(.*\)/\1$LOGDIR#/g' /etc/app/app.cfg
sed -i 's/LogDir[[:space:]]=.*/LogDir = {LOGDIR}/' /etc/app/app.cfg
sed -i "s/^LogDir[[:space:]]*=.*/LogDir=$LOGDIR/}" /etc/app/app.cfg
sed -i '/#/!s/\(LogDir[[:space:]]*=[[:space:]]*\)\(.*\)/\1"$LOGDIR"/' /etc/app/app.cfg

```

**Desired output:**

Update LogDir value in /etc/app/app.cfg

For example:

`LogDir = /mnt/eft/fs1/logs`