Many additions and changes
This commit is contained in:
27
scripts/shell/job/change-value-from-keyvalue-file.sh
Executable file
27
scripts/shell/job/change-value-from-keyvalue-file.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user