Check Variable Value in File and Replace If Needed Bash Script -


this question related post: setting variables value in file in different directory using loops , sed bash script

i'm looking way check variable value in file , update needed. change value following:

#!/bin/bash  cd '/home/me/' source server.properties server_var="$server_name" echo "$server_var" echo "$application_name" if [ "$server_var" != "server1" ];     echo "uncorrect value"     sed -i -e 's@server_name=$server_var@server_name=server1@g' server.properties fi cd '/home/test/' 

thank suggestion, if statement work, sed command doesnt update variable value in file. can please point me in right direction regarding issue?

thank you,

if [ -n "$server_name" ]     sed ... fi 

btw, don't think set command can set $server_name. set $1, $2, etc.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -