#!/bin/bash show_help() { echo "Usage: $0 [--files|-f files]" echo "Options:" echo " --help | -h (Optional) Display help information on how to use this script" echo " --key | -k (Required) Specify the key's name" echo " --new-value | -v (Required) Specify the new value for the key" echo " --file-path | -f (Required) Specify the file's path" } key='' new_value='' file_path='' while [ "$#" -gt 0 ]; do case "$1" in --help|-h) show_help; exit ;; --key|-k) key="$2"; shift 2;; --new-value|-v) new_value="$2"; shift 2;; --file-path|-f) file_path="$2"; shift 2;; *) shift ;; esac done old_value=`cat $file_path | grep $key | awk -F= '{print $2}'` sed -i "s/$old_value/$new_value/g" $file_path